summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala8
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala9
-rw-r--r--test/files/neg/bug729.check6
-rw-r--r--test/files/neg/bug729.scala23
-rw-r--r--test/files/neg/bug752.check6
-rw-r--r--test/files/neg/bug752.scala8
-rw-r--r--test/files/neg/viewtest.check4
7 files changed, 56 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index 3223349237..9f1d17fc8c 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -272,7 +272,11 @@ trait Infer requires Analyzer {
*/
private def withDisambiguation[T](tp1: Type, tp2: Type)(op: => T): T = {
- def explainName(sym: Symbol) = { sym.name = newTypeName(sym.name.toString+"(in "+sym.owner+")") }
+ def explainName(sym: Symbol) = {
+ if (!sym.name.toString.endsWith(")")) {
+ sym.name = newTypeName(sym.name.toString+"(in "+sym.owner+")")
+ }
+ }
val patches = {
val syms1 = typeRefs.collect(tp1)
@@ -286,7 +290,7 @@ trait Infer requires Analyzer {
explainName(sym1)
explainName(sym2)
if (sym1.owner == sym2.owner) sym2.name = newTypeName("(some other)"+sym2.name)
- Triple(sym1, sym2, sym1.name)
+ Triple(sym1, sym2, name)
}
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 756587fbba..4a4d6da251 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -501,8 +501,9 @@ trait Typers requires Analyzer {
case mt: MethodType
if (((mode & (EXPRmode | FUNmode | LHSmode)) == EXPRmode) &&
(context.undetparams.isEmpty || (mode & POLYmode) != 0)) =>
- if (!tree.symbol.isConstructor && pt != WildcardType &&
- isCompatible(tparamsToWildcards(mt, context.undetparams), pt) &&
+ if (!tree.symbol.isConstructor &&
+ //isCompatible(tparamsToWildcards(mt, context.undetparams), pt) &&
+ pt != WildcardType &&
(pt <:< functionType(mt.paramTypes map (t => WildcardType), WildcardType))) { // (4.2)
if (settings.debug.value) log("eta-expanding "+tree+":"+tree.tpe+" to "+pt)
checkParamsConvertible(tree.pos, tree.tpe)
@@ -599,7 +600,7 @@ trait Typers requires Analyzer {
} else if (tree.tpe <:< pt) {
tree
} else if ((mode & PATTERNmode) != 0) {
- if (tree.symbol.isModule) inferModulePattern(tree, pt)
+ if (tree.symbol != null && tree.symbol.isModule) inferModulePattern(tree, pt)
tree
} else {
val tree1 = constfold(tree, pt) // (10) (11)
@@ -1911,7 +1912,7 @@ trait Typers requires Analyzer {
case ErrorType =>
expr1
case _ =>
- errorTree(expr1, "`&' must be applied to method type; cannot be applied to " + expr1.tpe)
+ errorTree(expr1, "`&' must be applied to method; cannot be applied to " + expr1.tpe)
}
case Typed(expr, tpt @ Ident(name)) if (name == nme.WILDCARD_STAR.toTypeName) =>
diff --git a/test/files/neg/bug729.check b/test/files/neg/bug729.check
new file mode 100644
index 0000000000..8c13a304b3
--- /dev/null
+++ b/test/files/neg/bug729.check
@@ -0,0 +1,6 @@
+bug729.scala:20 error: type mismatch;
+ found : ScalaParserAutoEdit.this.NodeImpl(in trait Parser)
+ required: ScalaParserAutoEdit.this.NodeImpl(in trait ScalaParserAutoEdit)
+ val yyy : NodeImpl = link.from;
+ ^
+one error found
diff --git a/test/files/neg/bug729.scala b/test/files/neg/bug729.scala
new file mode 100644
index 0000000000..83e7f4cd1e
--- /dev/null
+++ b/test/files/neg/bug729.scala
@@ -0,0 +1,23 @@
+trait Parser {
+ type Node <: NodeImpl;
+ implicit def coerce(n : NodeImpl) = n.self;
+ trait NodeImpl {
+ def self : Node;
+ }
+ trait Link {
+ def from : NodeImpl;
+ }
+}
+
+trait ScalaParserAutoEdit extends Parser {
+ type Node <: NodeImpl;
+ implicit def coerce(node : NodeImpl) = node.self;
+ trait NodeImpl extends super[Parser].NodeImpl {
+ def self : Node;
+ def foo = {
+ var link : Link = null;
+ val xxx : NodeImpl = coerce(link.from);
+ val yyy : NodeImpl = link.from;
+ }
+ }
+}
diff --git a/test/files/neg/bug752.check b/test/files/neg/bug752.check
new file mode 100644
index 0000000000..a00ca01ced
--- /dev/null
+++ b/test/files/neg/bug752.check
@@ -0,0 +1,6 @@
+bug752.scala:6 error: type mismatch;
+ found : (java.lang.String) => scala.Unit
+ required: (scala.Int) => scala.Unit
+ f(&g)
+ ^
+one error found
diff --git a/test/files/neg/bug752.scala b/test/files/neg/bug752.scala
new file mode 100644
index 0000000000..aae0d5f4a7
--- /dev/null
+++ b/test/files/neg/bug752.scala
@@ -0,0 +1,8 @@
+object Test
+{
+ def f(x : Int => Unit) : Unit = ()
+ def g(x : String) : Unit = ()
+ def main(argv : Array[String]) = {
+ f(&g)
+ }
+}
diff --git a/test/files/neg/viewtest.check b/test/files/neg/viewtest.check
index 044c3b7d91..b7433f6818 100644
--- a/test/files/neg/viewtest.check
+++ b/test/files/neg/viewtest.check
@@ -1,6 +1,6 @@
viewtest.scala:43 error: type mismatch;
- found : scala.List[<type a in method compareTo>]
- required: scala.List[<type a in method view3>]
+ found : scala.List[a(in method compareTo)]
+ required: scala.List[a(in method view3)]
case y1: List[a] => compareLists(x, y1)
^
viewtest.scala:104 error: ambiguous implicit value: