summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala2
-rwxr-xr-xtest/files/neg/bug126.scala8
-rwxr-xr-xtest/files/pos/bug122.scala4
-rw-r--r--test/files/pos/bug616.scala11
-rw-r--r--test/files/run/bug216.scala7
-rw-r--r--test/files/run/lisp.scala14
-rwxr-xr-xtest/pending/pos/bug305.scala8
-rw-r--r--test/pending/pos/bug599.scala18
8 files changed, 63 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index ac8f976063..b2c408bf45 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -490,7 +490,7 @@ trait Typers requires Analyzer {
def adaptToMember(qual: Tree, name: Name, tp: Type): Tree = {
val qtpe = qual.tpe.widen;
- if (qual.isTerm && (qual.symbol == null || qual.symbol.isValue) &&
+ if (qual.isTerm && (qual.symbol == null || !qual.symbol.isTerm || qual.symbol.isValue) &&
!phase.erasedTypes && !qtpe.isError && !tp.isError &&
qtpe.symbol != AllRefClass && qtpe.symbol != AllClass && qtpe != WildcardType) {
val coercion = inferView(qual.pos, qtpe, name, tp, true)
diff --git a/test/files/neg/bug126.scala b/test/files/neg/bug126.scala
new file mode 100755
index 0000000000..75c10e608a
--- /dev/null
+++ b/test/files/neg/bug126.scala
@@ -0,0 +1,8 @@
+class O {
+ val Bar:Any => Any = ((x:Any) => Bar(x));
+ val Tuple2(foo:(Any => Any), bar) = Tuple2((x:Any) => foo(x), 1);
+ {
+ val Tuple1(foo2:(Any => Any)) = Tuple1((x:Any) => foo2(x));
+ Console.println(foo2)
+ }
+}
diff --git a/test/files/pos/bug122.scala b/test/files/pos/bug122.scala
new file mode 100755
index 0000000000..cbfdb64def
--- /dev/null
+++ b/test/files/pos/bug122.scala
@@ -0,0 +1,4 @@
+class L{
+ val List(v:int,2) = List(2,v:int);
+ val Pair(a:int,b:int) = Pair(1,a);
+} \ No newline at end of file
diff --git a/test/files/pos/bug616.scala b/test/files/pos/bug616.scala
new file mode 100644
index 0000000000..bf757a58d3
--- /dev/null
+++ b/test/files/pos/bug616.scala
@@ -0,0 +1,11 @@
+object testImplicit {
+ implicit def foo2bar(foo :Foo) :Bar = foo.bar
+ class Foo(val bar :Bar) {
+ def testCoercion = {val a = this; a.baz} // here, foo2bar is inferred by the compiler, as expected
+ //def testCoercionThisImplicit = baz // --> error: not found: value baz
+ def testCoercionThisExplicit: Any = this.baz // --> error: value baz is not a member of Foo
+ }
+ trait Bar { def baz :unit}
+}
+// mentioned before: http://thread.gmane.org/gmane.comp.lang.scala/2038,
+// but couldn't find a bug report
diff --git a/test/files/run/bug216.scala b/test/files/run/bug216.scala
new file mode 100644
index 0000000000..41b2af7b50
--- /dev/null
+++ b/test/files/run/bug216.scala
@@ -0,0 +1,7 @@
+object Test extends Application {
+ object m {
+ val f = x: unit => ();
+ Console.println("OK")
+ }
+ m;
+}
diff --git a/test/files/run/lisp.scala b/test/files/run/lisp.scala
index 34c4e7c7cc..cb26972e2d 100644
--- a/test/files/run/lisp.scala
+++ b/test/files/run/lisp.scala
@@ -15,14 +15,12 @@ class LispTokenizer(s: String) extends Iterator[String] {
}
def next: String =
if (hasNext) {
- val start = i;
- var ch = s.charAt(i); i = i + 1;
- if (ch == '(') "("
- else if (ch == ')') ")"
- else {
- while (i < s.length() && !isDelimiter(s.charAt(i))){ i = i + 1 }
- s.substring(start, i)
- }
+ val start = i
+ if (isDelimiter(s charAt i)) i = i + 1
+ else
+ do i = i + 1
+ while (!isDelimiter(s charAt i))
+ s.substring(start, i)
} else error("premature end of string")
}
diff --git a/test/pending/pos/bug305.scala b/test/pending/pos/bug305.scala
new file mode 100755
index 0000000000..3e7e8c60f4
--- /dev/null
+++ b/test/pending/pos/bug305.scala
@@ -0,0 +1,8 @@
+object Test extends Application {
+
+ def foo(is:int*) = 1;
+ def foo(i:int) = 2;
+
+ Console.println( foo( List(3):_* ) )
+
+} \ No newline at end of file
diff --git a/test/pending/pos/bug599.scala b/test/pending/pos/bug599.scala
new file mode 100644
index 0000000000..885159af66
--- /dev/null
+++ b/test/pending/pos/bug599.scala
@@ -0,0 +1,18 @@
+abstract class FooA {
+ type A <: Ax;
+ abstract class Ax;
+ abstract class InnerA {
+ type B <: A;
+ def doB : B;
+ }
+ }
+ trait FooB extends FooA {
+ type A <: Ax;
+ trait Ax extends super.Ax { def xxx : Int; }
+ abstract class InnerB extends InnerA {
+ // type B <: A;
+ val a : A = doB;
+ a.xxx;
+ doB.xxx;
+ }
+ }