Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemErrorsTest.java @ 18782:3ea386a1036f
Truffle-DSL: breaking: @TypeCheck and @TypeCast now require casted/checked type as explicit parameter. Previously the type was parsed from the method name. (GRAAL-446 #resolve)
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 05 Jan 2015 20:23:22 +0100 |
parents | 64dcb92ee75a |
children | 7d67a33e1bbb |
comparison
equal
deleted
inserted
replaced
18781:941761f6b736 | 18782:3ea386a1036f |
---|---|
36 @TypeSystem({CharSequence.class, String.class}) | 36 @TypeSystem({CharSequence.class, String.class}) |
37 public static class Types1 { | 37 public static class Types1 { |
38 | 38 |
39 } | 39 } |
40 | 40 |
41 @TypeSystem({int.class, boolean.class}) | |
42 public static class Types2 { | |
43 | |
44 @TypeCast | |
45 @ExpectError("The provided return type \"String\" does not match expected return type \"int\".%") | |
46 String asInteger(Object value) { | |
47 return (String) value; | |
48 } | |
49 | |
50 } | |
51 | |
52 @TypeSystem({int.class, boolean.class}) | |
53 public static class Types3 { | |
54 | |
55 @TypeCast | |
56 @ExpectError("The provided return type \"boolean\" does not match expected return type \"int\".%") | |
57 boolean asInteger(Object value) { | |
58 return (boolean) value; | |
59 } | |
60 | |
61 } | |
62 | |
63 @TypeSystemReference(Types0.class) | 41 @TypeSystemReference(Types0.class) |
64 @NodeChild | 42 @NodeChild |
65 @ExpectError("The @TypeSystem of the node and the @TypeSystem of the @NodeChild does not match. Types0 != SimpleTypes. ") | 43 @ExpectError("The @TypeSystem of the node and the @TypeSystem of the @NodeChild does not match. Types0 != SimpleTypes. ") |
66 abstract static class ErrorNode1 extends ValueNode { | 44 abstract static class ErrorNode1 extends ValueNode { |
45 } | |
67 | 46 |
47 @TypeSystem({int.class}) | |
48 public static class CastError1 { | |
49 @TypeCast(int.class) | |
50 @ExpectError("The provided return type \"String\" does not match expected return type \"int\".%") | |
51 public static String asInteger(Object value) { | |
52 return (String) value; | |
53 } | |
54 } | |
55 | |
56 @TypeSystem({int.class}) | |
57 public static class CastError2 { | |
58 @TypeCast(int.class) | |
59 @ExpectError("The provided return type \"boolean\" does not match expected return type \"int\".%") | |
60 public static boolean asInteger(Object value) { | |
61 return (boolean) value; | |
62 } | |
63 } | |
64 | |
65 @TypeSystem({boolean.class}) | |
66 public static class CastError3 { | |
67 @ExpectError("The type 'int' is not declared in the @TypeSystem.") | |
68 @TypeCast(int.class) | |
69 public static int asInt(Object value) { | |
70 return (int) value; | |
71 } | |
72 } | |
73 | |
74 @TypeSystem({int.class}) | |
75 public static class CastError4 { | |
76 @ExpectError("@TypeCast annotated method asInt must be public and static.") | |
77 @TypeCast(int.class) | |
78 public int asInt(Object value) { | |
79 return (int) value; | |
80 } | |
81 } | |
82 | |
83 @TypeSystem({int.class}) | |
84 public static class CastError5 { | |
85 @ExpectError("@TypeCast annotated method asInt must be public and static.") | |
86 @TypeCast(int.class) | |
87 static int asInt(Object value) { | |
88 return (int) value; | |
89 } | |
90 } | |
91 | |
92 @TypeSystem({boolean.class}) | |
93 public static class CheckError1 { | |
94 @ExpectError("The type 'int' is not declared in the @TypeSystem.") | |
95 @TypeCheck(int.class) | |
96 public static boolean isInt(Object value) { | |
97 return value instanceof Integer; | |
98 } | |
99 } | |
100 | |
101 @TypeSystem({int.class}) | |
102 public static class CheckError2 { | |
103 @ExpectError("@TypeCheck annotated method isInt must be public and static.") | |
104 @TypeCheck(int.class) | |
105 public boolean isInt(Object value) { | |
106 return value instanceof Integer; | |
107 } | |
108 } | |
109 | |
110 @TypeSystem({int.class}) | |
111 public static class CheckError3 { | |
112 @ExpectError("@TypeCheck annotated method isInt must be public and static.") | |
113 @TypeCheck(int.class) | |
114 static boolean isInt(Object value) { | |
115 return value instanceof Integer; | |
116 } | |
68 } | 117 } |
69 | 118 |
70 } | 119 } |