summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala8
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala9
3 files changed, 17 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index ad3d99b680..33eff2fb8a 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -3080,8 +3080,10 @@ A type's typeSymbol should never be inspected directly.
if (!corresponds(sym.owner, rebind0.owner)) {
if (settings.debug.value) Console.println("ADAPT1 pre = "+pre+", sym = "+sym+sym.locationString+", rebind = "+rebind0+rebind0.locationString)
val bcs = pre.baseClasses.dropWhile(bc => !corresponds(bc, sym.owner));
- assert(!bcs.isEmpty)
- rebind0 = pre.baseType(bcs.head).member(sym.name)
+ if (bcs.isEmpty)
+ assert(pre.typeSymbol.isRefinementClass, pre) // if pre is a refinementclass it might be a structural type => OK to leave it in.
+ else
+ rebind0 = pre.baseType(bcs.head).member(sym.name)
if (settings.debug.value) Console.println("ADAPT2 pre = "+pre+", bcs.head = "+bcs.head+", sym = "+sym+sym.locationString+", rebind = "+rebind0+(if (rebind0 == NoSymbol) "" else rebind0.locationString))
}
val rebind = rebind0.suchThat(sym => sym.isType || sym.isStable)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index d3b08886fb..ece9bc1028 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -135,12 +135,16 @@ trait Namers { self: Analyzer =>
private def doubleDefError(pos: Position, sym: Symbol) {
context.error(pos,
sym.name.toString() + " is already defined as " +
+ (if (sym.hasFlag(SYNTHETIC))
+ "(compiler-generated) "+ (if (sym.isModule) "case class companion " else "")
+ else "") +
(if (sym.hasFlag(CASE)) "case class " + sym.name else sym.toString()))
}
- private def inCurrentScope(m: Symbol) =
+ private def inCurrentScope(m: Symbol): Boolean = {
if (context.owner.isClass) context.owner == m.owner
- else context.scope == m.owner.info.decls
+ else m.owner.isClass && context.scope == m.owner.info.decls
+ }
def enterInScope(sym: Symbol): Symbol = enterInScope(sym, context.scope)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index d410bf6eee..a1c99aa049 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -2384,7 +2384,10 @@ trait Typers { self: Analyzer =>
def typedReturn(expr: Tree) = {
val enclMethod = context.enclMethod
- if (enclMethod == NoContext || enclMethod.owner.isConstructor) {
+ if (enclMethod == NoContext ||
+ enclMethod.owner.isConstructor ||
+ context.enclClass.enclMethod == enclMethod // i.e., we are in a constructor of a local class
+ ) {
errorTree(tree, "return outside method definition")
} else {
val DefDef(_, _, _, _, restpt, _) = enclMethod.tree
@@ -2701,7 +2704,9 @@ trait Typers { self: Analyzer =>
}
val owntype =
if (mix.isEmpty) {
- if ((mode & SUPERCONSTRmode) != 0) clazz.info.parents.head
+ if ((mode & SUPERCONSTRmode) != 0)
+ if (clazz.info.parents.isEmpty) AnyRefClass.tpe // can happen due to cyclic references ==> #1036
+ else clazz.info.parents.head
else intersectionType(clazz.info.parents)
} else {
findMixinSuper(clazz.info)