Skip to content

Instantly share code, notes, and snippets.

@taku0
Created July 2, 2016 14:07
Show Gist options
  • Save taku0/e0da85dff15c8120e4a3b7c6a6c43fc2 to your computer and use it in GitHub Desktop.
Save taku0/e0da85dff15c8120e4a3b7c6a6c43fc2 to your computer and use it in GitHub Desktop.
Exponential type checking
class Tuple<T, R> {
}
class Bar<T> {
public Bar<Tuple<T, T>> d() {
return null;
}
public void bar() {
Bar<Integer> x = d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d();
}
}
class Bar[T] {
def d(): Bar[(T, T)] = null
def bar() {
val x: Bar[Integer] = d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d()
}
}
class Foo<T, R> {
public <T> Foo<T, T> d(T t) {
return null;
}
public void foo() {
Foo<Integer, Integer> foo = d(d(d(d(d(d(d(d(d(dd(d(d(d(d(d(d(d(d(d(d(d(d(d(d(d(d(d(d(d(1)))))))))))))))))))))))))))));
}
}
// scalac -J-Xmx4G -J-server exp.scala
class Foo {
val t0 = (0, 0)
val t1 = (t0, t0)
val t2 = (t1, t1)
val t3 = (t2, t2)
val t4 = (t3, t3)
val t5 = (t4, t4)
val t6 = (t5, t5)
val t7 = (t6, t6)
val t8 = (t7, t7)
val t9 = (t8, t8)
val t10 = (t9, t9)
val t11 = (t10, t10)
val t12 = (t11, t11)
val t13 = (t12, t12)
val t14 = (t13, t13)
val t15 = (t14, t14)
val t16 = (t15, t15)
val t17 = (t16, t16)
val t18 = (t17, t17)
val t19 = (t18, t18)
val t20 = (t19, t19)
val t21 = (t20, t20)
val t22 = (t21, t21)
val t23 = (t22, t22)
val t24 = (t23, t23)
val t25: (Int, Int) = (t24, t24)
// val t26 = (t25, t25)
// val t27 = (t26, t26)
// val t28 = (t27, t27)
// val t29 = (t28, t28)
// val t30 = (t29, t29)
// val t31 = (t30, t30)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment