| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Scala
Revision: 16017
Author: DRMacIver
Date: 04 Sep 2008 09:54:09
Diff at Trac: https://lampsvn.epfl.ch/trac/scala/changeset/16017
Changes:Fixed RefChecks to not replace unapplies with constructors (ticket 0508). Moved test for this from pending to main tests.
Files:| ... | ...@@ -774,6 +774,8 @@ | |
| 774 | 774 | false |
| 775 | 775 | } |
| 776 | 776 | |
| 777 | def isCaseApply(sym : Symbol) = sym.isSourceMethod && sym.hasFlag(CASE) && sym.name == nme.apply | |
| 778 | ||
| 777 | 779 | val savedLocalTyper = localTyper |
| 778 | 780 | val savedCurrentApplication = currentApplication |
| 779 | 781 | val sym = tree.symbol |
| ... | ...@@ -810,7 +812,7 @@ | |
| 810 | 812 | } |
| 811 | 813 | case TypeApply(fn, args) => |
| 812 | 814 | checkBounds(NoPrefix, NoSymbol, fn.tpe.typeParams, args map (_.tpe)) |
| 813 | if (sym.isSourceMethod && sym.hasFlag(CASE)) result = toConstructor(tree.pos, tree.tpe) | |
| 815 | if (isCaseApply(sym)) result = toConstructor(tree.pos, tree.tpe) | |
| 814 | 816 | |
| 815 | 817 | case Apply( |
| 816 | 818 | Select(qual, nme.filter), |
| ... | ...@@ -842,7 +844,7 @@ | |
| 842 | 844 | "(such annotations are only allowed in arguments to *-parameters)") |
| 843 | 845 | |
| 844 | 846 | case Ident(name) => |
| 845 | if (sym.isSourceMethod && sym.hasFlag(CASE)) | |
| 847 | if (isCaseApply(sym)) | |
| 846 | 848 | result = toConstructor(tree.pos, tree.tpe) |
| 847 | 849 | else if (name != nme.WILDCARD && name != nme.WILDCARD_STAR.toTypeName) { |
| 848 | 850 | assert(sym != NoSymbol, tree)//debug |
| ... | ...@@ -860,7 +862,7 @@ | |
| 860 | 862 | } |
| 861 | 863 | if (!hidden) escapedPrivateLocals += sym |
| 862 | 864 | } |
| 863 | if (sym.isSourceMethod && sym.hasFlag(CASE)) | |
| 865 | if (isCaseApply(sym)) | |
| 864 | 866 | result = toConstructor(tree.pos, tree.tpe) |
| 865 | 867 | else qual match { |
| 866 | 868 | case Super(qualifier, mix) => |
| ... | ...@@ -0,0 +1,13 @@ | |
| 1 | object Test extends Application { | |
| 2 | ||
| 3 | case class Foo(s: String, n: Int) | |
| 4 | ||
| 5 | def foo[A, B, C](unapply1: A => Option[(B, C)], v: A) = { | |
| 6 | unapply1(v) match { | |
| 7 | case Some((fst, snd)) => println("first: " + fst, " second: " + snd) | |
| 8 | case _ => println(":(") | |
| 9 | } | |
| 10 | } | |
| 11 | ||
| 12 | foo(Foo.unapply, Foo("this might be fun", 10)) | |
| 13 | } |
| ... | ...@@ -1,13 +0,0 @@ | |
| 1 | object Test extends Application { | |
| 2 | ||
| 3 | case class Foo(s: String, n: Int) | |
| 4 | ||
| 5 | def foo[A, B, C](unapply1: A => Option[(B, C)], v: A) = { | |
| 6 | unapply1(v) match { | |
| 7 | case Some((fst, snd)) => println("first: " + fst, " second: " + snd) | |
| 8 | case _ => println(":(") | |
| 9 | } | |
| 10 | } | |
| 11 | ||
| 12 | foo(Foo.unapply, Foo("this might be fun", 10)) | |
| 13 | } |