summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala4
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala17
-rw-r--r--test/files/neg/t0003.check6
-rw-r--r--test/files/neg/t0003.scala3
-rw-r--r--test/files/neg/t0015.check11
-rw-r--r--test/files/neg/t0015.scala25
6 files changed, 62 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index 8d0a6f9649..5cba998f38 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -43,6 +43,7 @@ trait Symbols {
var rawflags: Long = 0
private var rawpos = initPos
val id = { ids += 1; ids }
+// assert(id != 4699, initName+"/"+initOwner)
var validTo: Period = NoPeriod
@@ -1333,8 +1334,7 @@ trait Symbols {
override def name: Name =
if (phase.flatClasses && rawowner != NoSymbol && !rawowner.isPackageClass) {
if (flatname == nme.EMPTY) {
- if(!rawowner.isClass) { Console.print("warning, is not a class, actually: "+rawowner.name.toString)}
- //assert(rawowner.isClass) //bq: assert here shadows more important messages
+ assert(rawowner.isClass)
flatname = newTypeName(rawowner.name.toString() + "$" + rawname)
}
flatname
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index a634233d74..3017d0e74b 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -236,7 +236,7 @@ trait Types {
*/
def typeOfThis: Type = typeSymbol.typeOfThis
- /** Map to a this type which is a subtype of this type.
+ /** Map to a singleton type which is a subtype of this type.
*/
def narrow: Type =
if (phase.erasedTypes) this
@@ -862,6 +862,7 @@ trait Types {
}
underlyingCache
}
+/*
override def narrow: Type = {
if (phase.erasedTypes) this
else {
@@ -873,6 +874,8 @@ trait Types {
thissym.thisType
}
}
+*/
+ override def narrow: Type = this
override def termSymbol = sym
@deprecated override def symbol = sym
@@ -1338,10 +1341,16 @@ A type's typeSymbol should never be inspected directly.
override def typeOfThis = transform(sym.typeOfThis)
+/*
override def narrow =
if (sym.isModuleClass) transform(sym.thisType)
else if (sym.isAliasType) normalize.narrow
else super.narrow
+*/
+ override def narrow =
+ if (sym.isModuleClass) singleType(pre, sym.sourceModule)
+ else if (sym.isAliasType) normalize.narrow
+ else super.narrow
override def prefix: Type =
if (sym.isAliasType) normalize.prefix
@@ -3480,7 +3489,11 @@ A type's typeSymbol should never be inspected directly.
case ex: NoCommonType =>
}
}
- if (lubRefined.decls.isEmpty) lubBase else lubRefined
+ if (lubRefined.decls.isEmpty) lubBase
+ else {
+// println("refined lub of "+ts+"/"+narrowts+" is "+lubRefined+", baseclasses = "+(ts map (_.closure) map (_.toList)))
+ lubRefined
+ }
}
existentialAbstraction(tparams, lubType)
}
diff --git a/test/files/neg/t0003.check b/test/files/neg/t0003.check
new file mode 100644
index 0000000000..5e29b189db
--- /dev/null
+++ b/test/files/neg/t0003.check
@@ -0,0 +1,6 @@
+t0003.scala:2: error: type mismatch;
+ found : (A) => (B) => B
+ required: (?) => B
+ def foo[A, B, C](l: List[A], f: A => B=>B, g: B=>B=>C): List[C] = l map (g compose f)
+ ^
+one error found
diff --git a/test/files/neg/t0003.scala b/test/files/neg/t0003.scala
new file mode 100644
index 0000000000..e41cfa9e9e
--- /dev/null
+++ b/test/files/neg/t0003.scala
@@ -0,0 +1,3 @@
+object Test {
+ def foo[A, B, C](l: List[A], f: A => B=>B, g: B=>B=>C): List[C] = l map (g compose f)
+}
diff --git a/test/files/neg/t0015.check b/test/files/neg/t0015.check
new file mode 100644
index 0000000000..2979237c0a
--- /dev/null
+++ b/test/files/neg/t0015.check
@@ -0,0 +1,11 @@
+t0015.scala:5: error: type mismatch;
+ found : () => Nothing
+ required: (Nothing) => ?
+ Nil.map(f _)
+ ^
+t0015.scala:21: error: type mismatch;
+ found : M
+ required: M.this.selfType
+ f[Int](self: selfType)
+ ^
+two errors found
diff --git a/test/files/neg/t0015.scala b/test/files/neg/t0015.scala
new file mode 100644
index 0000000000..35a6cd11fc
--- /dev/null
+++ b/test/files/neg/t0015.scala
@@ -0,0 +1,25 @@
+abstract class Test
+{
+ def f: Nothing
+
+ Nil.map(f _)
+}
+
+abstract class M
+{ self =>
+
+ type T
+ final type selfType = M {type T = self.T}
+ type actualSelfType >: self.type <: selfType
+
+
+ def f[U](x: Any) = {}
+
+ // compiles successfully
+ //f[Int](self: actualSelfType)
+
+ f[Int](self: selfType)
+
+ //def g(x: Any) = {}
+ //g(self: selfType)
+}