Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10157 from joroKr21/sammy-refined
Enable SAM syntax to refine type members
- Loading branch information
Showing
5 changed files
with
77 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,74 @@ | ||
sammy_restrictions.scala:38: error: type mismatch; | ||
sammy_restrictions.scala:40: error: type mismatch; | ||
found : () => Int | ||
required: NoAbstract | ||
def f0 = (() => 0) : NoAbstract | ||
^ | ||
sammy_restrictions.scala:39: error: type mismatch; | ||
sammy_restrictions.scala:41: error: type mismatch; | ||
found : Int => Int | ||
required: TwoAbstract | ||
def f1 = ((x: Int) => 0): TwoAbstract | ||
^ | ||
sammy_restrictions.scala:40: error: type mismatch; | ||
sammy_restrictions.scala:42: error: type mismatch; | ||
found : Int => Int | ||
required: NoEmptyConstructor | ||
def f2 = ((x: Int) => 0): NoEmptyConstructor | ||
^ | ||
sammy_restrictions.scala:41: error: type mismatch; | ||
sammy_restrictions.scala:43: error: type mismatch; | ||
found : Int => Int | ||
required: MultipleConstructorLists | ||
def f3 = ((x: Int) => 0): MultipleConstructorLists | ||
^ | ||
sammy_restrictions.scala:42: error: type mismatch; | ||
sammy_restrictions.scala:44: error: type mismatch; | ||
found : Int => Int | ||
required: OneEmptySecondaryConstructor | ||
def f4 = ((x: Int) => 0): OneEmptySecondaryConstructor // derived class must have an empty *primary* to call. | ||
^ | ||
sammy_restrictions.scala:43: error: type mismatch; | ||
sammy_restrictions.scala:45: error: type mismatch; | ||
found : Int => Int | ||
required: MultipleMethodLists | ||
def f5 = ((x: Int) => 0): MultipleMethodLists | ||
^ | ||
sammy_restrictions.scala:44: error: type mismatch; | ||
sammy_restrictions.scala:46: error: type mismatch; | ||
found : Int => Int | ||
required: ImplicitConstructorParam | ||
def f6 = ((x: Int) => 0): ImplicitConstructorParam | ||
^ | ||
sammy_restrictions.scala:45: error: type mismatch; | ||
sammy_restrictions.scala:47: error: type mismatch; | ||
found : Int => Int | ||
required: ImplicitMethodParam | ||
def f7 = ((x: Int) => 0): ImplicitMethodParam | ||
^ | ||
sammy_restrictions.scala:46: error: type mismatch; | ||
sammy_restrictions.scala:48: error: type mismatch; | ||
found : Int => Int | ||
required: PolyMethod | ||
def f8 = ((x: Int) => 0): PolyMethod | ||
^ | ||
sammy_restrictions.scala:47: error: type mismatch; | ||
sammy_restrictions.scala:49: error: type mismatch; | ||
found : Int => Int | ||
required: SelfTp | ||
def f9 = ((x: Int) => 0): SelfTp | ||
^ | ||
sammy_restrictions.scala:48: error: type mismatch; | ||
sammy_restrictions.scala:50: error: type mismatch; | ||
found : Int => Int | ||
required: T1 with U1 | ||
def g0 = ((x: Int) => 0): T1 with U1 | ||
^ | ||
sammy_restrictions.scala:49: error: type mismatch; | ||
sammy_restrictions.scala:51: error: type mismatch; | ||
found : Int => Int | ||
required: Test.NonClassTypeRefinement | ||
(which expands to) DerivedOneAbstract with OneAbstract | ||
def g1 = ((x: Int) => 0): NonClassTypeRefinement | ||
^ | ||
12 errors | ||
sammy_restrictions.scala:52: error: type mismatch; | ||
found : Int => Int | ||
required: Test.NonOverridingMethodRefinement | ||
(which expands to) OneAbstract{def apples(): Int} | ||
def h1 = ((x: Int) => 0): NonOverridingMethodRefinement | ||
^ | ||
sammy_restrictions.scala:53: error: type mismatch; | ||
found : Int => Int | ||
required: Test.OverridingMethodRefinement | ||
(which expands to) OneAbstract{def ap(a: Int): Int} | ||
def h2 = ((x: Int) => 0): OverridingMethodRefinement | ||
^ | ||
14 errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
trait DepFn[-A] { | ||
type Out | ||
def apply(in: A): Out | ||
} | ||
|
||
object DepFn { | ||
type Aux[-A, B] = DepFn[A] { type Out = B } | ||
type AuxF[F[_], A] = Aux[F[A], F[A]] { type B >: A } | ||
val length: DepFn[String] { type Out = Int } = _.length | ||
val upper: Aux[String, String] = _.toUpperCase | ||
val reverse: AuxF[List, Int] = _.reverse | ||
} | ||
|
||
class Outer { | ||
// T here does not compile to a SAM in bytecode, | ||
// because of the outer reference to the enclosing class. | ||
trait T { def f(x: Int): Int } | ||
val t1: T = x => x | ||
val t2: T { type U = String } = x => x | ||
val t3: T { type U } = x => x | ||
val t4: (T { type U }) { type V } = x => x | ||
} |