diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Symbols.scala | 7 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 9 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index c4407e1f0b..cbe3d3f172 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -386,6 +386,13 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable => final def isVariable = isTerm && hasFlag(MUTABLE) && !isMethod + // See bugs #1392 and #3123 - this exists specifically to exclude the faux + // companion objects of scala.Int and etc. from appearing to be stable identifiers + // and then crashing the backend. This is surely better handled a different + // way (personally I would vote for making those companion objects real objects + // unless that is impossible.) + def isNotAValue = !isValue || (isModule && isValueClass(linkedClassOfModule)) + // interesting only for lambda lift. Captured variables are accessed from inner lambdas. final def isCapturedVariable = isVariable && hasFlag(CAPTURED) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 504e940848..98ee29c32b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -642,16 +642,15 @@ trait Typers { self: Analyzer => * </ol> */ private def stabilize(tree: Tree, pre: Type, mode: Int, pt: Type): Tree = { - def isNotAValue(sym: Symbol) = // bug #1392 - !sym.isValue || (sym.isModule && isValueClass(sym.linkedClassOfModule)) - if (tree.symbol.hasFlag(OVERLOADED) && (mode & FUNmode) == 0) inferExprAlternative(tree, pt) val sym = tree.symbol + if (tree.tpe.isError) tree else if ((mode & (PATTERNmode | FUNmode)) == PATTERNmode && tree.isTerm) { // (1) - checkStable(tree) - } else if ((mode & (EXPRmode | QUALmode)) == EXPRmode && isNotAValue(sym) && !phase.erasedTypes) { // (2) + if (sym.isNotAValue) errorTree(tree, sym+" is not a value") + else checkStable(tree) + } else if ((mode & (EXPRmode | QUALmode)) == EXPRmode && sym.isNotAValue && !phase.erasedTypes) { // (2) errorTree(tree, sym+" is not a value") } else { if (sym.isStable && pre.isStable && tree.tpe.typeSymbol != ByNameParamClass && |