This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 270875 - Code model erroneously distinguishes structs and classes
Summary: Code model erroneously distinguishes structs and classes
Status: REOPENED
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 8.1
Hardware: All All
: P3 normal (vote)
Assignee: Vladimir Kvashin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-14 07:50 UTC by Vladimir Kvashin
Modified: 2017-06-15 07:07 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Proposed fix (1.16 KB, patch)
2017-06-15 06:59 UTC, Vladimir Kvashin
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Kvashin 2017-06-14 07:50:33 UTC
The following example shows that code model erroneously distinguishes structs and classes. There is a slight inconsistency in code: traits sometimes is class and sometimes is struct. But from C++ point of view it's ok. It compiles without warnings and works well. However IDE does not show traits<Function>  and traits<Variable> in the list of specializations.

That's because their kinds are different => they can not be properly found in code model maps. Sure this fact has more consequences.

#include <iostream>

using namespace std;

class Function {};
class Variable {};

// has a gray "T" but navigates ONLY to the line 16
template <typename NodeTy> struct traits {
public:
    static void echo() { cout << "Generic" << endl; }
};

template<typename NodeTy> class list {
public:    
  friend struct traits<NodeTy>;
  void some_other_stuff();
};

template <> class traits<Function> { // has a green "T"
public:    
    static void echo() { cout << "Function" << endl; }
};

template <> class traits<Variable> { // has a green "T"
public:    
    static void echo() { cout << "Variable" << endl; }
};

int main(int argc, char** argv) {
    traits<int>::echo();
    traits<Function>::echo();
    traits<Variable>::echo();
    return 0;
}
Comment 1 Vladimir Kvashin 2017-06-14 07:59:50 UTC
Fixed in cnd-main
http://hg.netbeans.org/cnd-main/rev/8e56290210ce
Comment 2 Vladimir Kvashin 2017-06-14 08:46:43 UTC
(In reply to Vladimir Kvashin from comment #1)
> Fixed in cnd-main
> http://hg.netbeans.org/cnd-main/rev/8e56290210ce
Sorry, I meant issue #270874
Comment 3 Vladimir Kvashin 2017-06-15 06:59:33 UTC
Created attachment 164545 [details]
Proposed fix
Comment 4 Vladimir Kvashin 2017-06-15 07:07:37 UTC
I'm pretty sure that we should change Utils.getCsmDeclarationKindkey() so that it returns the same prefix for classes and structs. Crunches we discussed yesterday look horrible, change many places in code instead of fixing the one that is the root cause... yuk.