Skip to content

Commit

Permalink
Fix TypeGuessing (don't unintentionally create ref locals)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgrunwald committed Nov 25, 2016
1 parent 3c638f6 commit ab1c338
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 0 additions & 1 deletion ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3212,7 +3212,6 @@ int consume_string (bool quoted)

value_builder[pos++] = (char) c;
}
recordNewLine = true;
}

private int consume_identifier (int s)
Expand Down
2 changes: 2 additions & 0 deletions ICSharpCode.NRefactory.CSharp/Refactoring/TypeGuessing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ public static AstType GuessAstType(RefactoringContext context, AstNode expr)
var typeInference = new TypeInference(context.Compilation);
typeInference.Algorithm = TypeInferenceAlgorithm.Improved;
var inferedType = typeInference.FindTypeInBounds(type, emptyTypes);
if (inferedType.Kind == TypeKind.ByReference)
inferedType = ((ByReferenceType)inferedType).ElementType;
if (inferedType.Kind == TypeKind.Unknown)
return new PrimitiveType("object");
return context.CreateShortType(inferedType);
Expand Down

0 comments on commit ab1c338

Please sign in to comment.