Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rosetta): go may incorrectly emit _ instead of . #3985

Merged
merged 4 commits into from
Feb 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions packages/jsii-rosetta/lib/languages/go.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,13 +487,14 @@ export class GoVisitor extends DefaultVisitor<GoLanguageContext> {
const isClassStaticMethodAccess =
isStaticMember && !isClassStaticPropertyAccess && ts.isMethodDeclaration(valueSymbol.valueDeclaration);

// When the expression has an unknown type (unresolved symbol), and has an upper-case first
// letter, we assume it's a type name... In such cases, what comes after can be considered a
// static member access. Note that the expression might be further qualified, so we check using
// a regex that checks for the last "."-delimited segment if there's dots in there...
// When the expression has an unknown type (unresolved symbol), has an upper-case first letter,
// and doesn't end in a call expression (as hinted by the presence of parentheses), we assume
// it's a type name... In such cases, what comes after can be considered a static member access.
// Note that the expression might be further qualified, so we check using a regex that checks
// for the last "." - delimited segment if there's dots in there...
const expressionLooksLikeTypeReference =
expressionType.symbol == null &&
/(?:\.|^)[A-Z][^.]*$/.exec(node.expression.getText(node.expression.getSourceFile())) != null;
/(?:\.|^)[A-Z][^.)]*$/.exec(node.expression.getText(node.expression.getSourceFile())) != null;

// Whether the node is an enum member reference.
const isEnumMember =
Expand Down