[groovy] update 'Cannot cast' inspection

- move all cast logic into single type converter
- fix tests
- do not rely on TypesUtil.isNumeric()
This commit is contained in:
Daniil Ovchinnikov
2017-01-24 23:02:38 +03:00
parent 2bbcff613a
commit 6d7144fa10
14 changed files with 681 additions and 563 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,7 +43,6 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod;
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList;
@@ -386,7 +385,7 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl<GrExpressi
if (resolvedF instanceof GrField) {
type = ((GrField)resolvedF).getType();
}
else if (resolvedF instanceof GrVariable && !(resolvedF instanceof GrParameter)) {
else if (resolvedF instanceof GrVariable) {
type = ((GrVariable)resolvedF).getDeclaredType();
}
else if (resolvedF instanceof GrAccessorMethod) {
@@ -0,0 +1,47 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions;
import com.intellij.psi.PsiClassType;
import com.intellij.psi.PsiPrimitiveType;
import com.intellij.psi.PsiType;
import org.jetbrains.annotations.Nullable;
import static org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil.TYPE_TO_RANK;
import static org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil.getQualifiedName;
public interface TypeConstants {
int BYTE_RANK = 1;
int CHARACTER_RANK = 2;
int SHORT_RANK = 3;
int INTEGER_RANK = 4;
int LONG_RANK = 5;
int BIG_INTEGER_RANK = 6;
int BIG_DECIMAL_RANK = 7;
int FLOAT_RANK = 8;
int DOUBLE_RANK = 9;
static int getTypeRank(@Nullable PsiType type) {
if (type instanceof PsiClassType) {
return TYPE_TO_RANK.get(getQualifiedName(type));
}
else if (type instanceof PsiPrimitiveType) {
return TYPE_TO_RANK.get(((PsiPrimitiveType)type).getBoxedTypeName());
}
return 0;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -61,7 +61,7 @@ import static org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.
/**
* @author ven
*/
public class TypesUtil {
public class TypesUtil implements TypeConstants {
@NonNls
public static final Map<String, PsiType> ourQNameToUnboxed = new HashMap<>();
@@ -165,18 +165,19 @@ public class TypesUtil {
ourUnaryOperationsToOperatorNames.put(GroovyTokenTypes.mBNOT, BITWISE_NEGATE);
}
private static final TObjectIntHashMap<String> TYPE_TO_RANK = new TObjectIntHashMap<>();
static final TObjectIntHashMap<String> TYPE_TO_RANK = new TObjectIntHashMap<>();
static {
TYPE_TO_RANK.put(CommonClassNames.JAVA_LANG_BYTE, 1);
TYPE_TO_RANK.put(CommonClassNames.JAVA_LANG_SHORT, 2);
TYPE_TO_RANK.put(CommonClassNames.JAVA_LANG_INTEGER, 3);
TYPE_TO_RANK.put(CommonClassNames.JAVA_LANG_LONG, 4);
TYPE_TO_RANK.put(GroovyCommonClassNames.JAVA_MATH_BIG_INTEGER, 5);
TYPE_TO_RANK.put(GroovyCommonClassNames.JAVA_MATH_BIG_DECIMAL, 6);
TYPE_TO_RANK.put(CommonClassNames.JAVA_LANG_FLOAT, 7);
TYPE_TO_RANK.put(CommonClassNames.JAVA_LANG_DOUBLE, 8);
TYPE_TO_RANK.put(CommonClassNames.JAVA_LANG_NUMBER, 9);
TYPE_TO_RANK.put(CommonClassNames.JAVA_LANG_BYTE, BYTE_RANK);
TYPE_TO_RANK.put(CommonClassNames.JAVA_LANG_CHARACTER, CHARACTER_RANK);
TYPE_TO_RANK.put(CommonClassNames.JAVA_LANG_SHORT, SHORT_RANK);
TYPE_TO_RANK.put(CommonClassNames.JAVA_LANG_INTEGER, INTEGER_RANK);
TYPE_TO_RANK.put(CommonClassNames.JAVA_LANG_LONG, LONG_RANK);
TYPE_TO_RANK.put(GroovyCommonClassNames.JAVA_MATH_BIG_INTEGER, BIG_INTEGER_RANK);
TYPE_TO_RANK.put(GroovyCommonClassNames.JAVA_MATH_BIG_DECIMAL, BIG_DECIMAL_RANK);
TYPE_TO_RANK.put(CommonClassNames.JAVA_LANG_FLOAT, FLOAT_RANK);
TYPE_TO_RANK.put(CommonClassNames.JAVA_LANG_DOUBLE, DOUBLE_RANK);
TYPE_TO_RANK.put(CommonClassNames.JAVA_LANG_NUMBER, 10);
}
private static final List<PsiType> LUB_NUMERIC_TYPES = ContainerUtil.newArrayList(
@@ -277,6 +278,7 @@ public class TypesUtil {
@NotNull PsiElement context,
@NotNull ApplicableTo position) {
if (!(context instanceof GroovyPsiElement)) return null;
if (targetType.equals(actualType)) return ConversionResult.OK;
for (GrTypeConverter converter : GrTypeConverter.EP_NAME.getExtensions()) {
if (!converter.isApplicableTo(position)) continue;
final ConversionResult result = converter.isConvertibleEx(targetType, actualType, (GroovyPsiElement)context, position);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@ public class GrBooleanTypeConverter extends GrTypeConverter {
@Override
public boolean isApplicableTo(@NotNull ApplicableTo position) {
return true;
return position != ApplicableTo.EXPLICIT_CAST;
}
@Nullable
@@ -43,7 +43,6 @@ public class GrBooleanTypeConverter extends GrTypeConverter {
switch (currentPosition) {
case METHOD_PARAMETER:
return null;
case EXPLICIT_CAST:
case ASSIGNMENT:
case RETURN_VALUE:
return ConversionResult.OK;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ public class GrCharConverter extends GrTypeConverter {
@Override
public boolean isApplicableTo(@NotNull ApplicableTo position) {
return position == ApplicableTo.EXPLICIT_CAST || position == ApplicableTo.ASSIGNMENT || position == ApplicableTo.RETURN_VALUE;
return position == ApplicableTo.ASSIGNMENT || position == ApplicableTo.RETURN_VALUE;
}
@Nullable
@@ -45,10 +45,9 @@ public class GrCharConverter extends GrTypeConverter {
if (!PsiType.CHAR.equals(TypesUtil.unboxPrimitiveTypeWrapper(lType))) return null;
if (PsiType.CHAR.equals(TypesUtil.unboxPrimitiveTypeWrapper(rType))) return ConversionResult.OK;
// can cast and assign numeric types to char
// can assign numeric types to char
if (TypesUtil.isNumericType(rType)) {
if (rType instanceof PsiPrimitiveType ||
currentPosition != ApplicableTo.EXPLICIT_CAST && TypesUtil.unboxPrimitiveTypeWrapper(rType) instanceof PsiPrimitiveType) {
if (rType instanceof PsiPrimitiveType || TypesUtil.unboxPrimitiveTypeWrapper(rType) instanceof PsiPrimitiveType) {
return PsiType.CHAR.equals(lType) ? ConversionResult.OK : ConversionResult.ERROR;
}
else {
@@ -78,8 +77,6 @@ public class GrCharConverter extends GrTypeConverter {
if (PsiType.BOOLEAN.equals(TypesUtil.unboxPrimitiveTypeWrapper(rType))) {
switch (currentPosition) {
case EXPLICIT_CAST:
return ConversionResult.ERROR;
case ASSIGNMENT:
case RETURN_VALUE:
return ConversionResult.WARNING;
@@ -96,8 +93,12 @@ public class GrCharConverter extends GrTypeConverter {
// can cast and assign one-symbol strings to char
if (!TypesUtil.isClassType(rType, CommonClassNames.JAVA_LANG_STRING)) return null;
return checkSingleSymbolLiteral(context) ? ConversionResult.OK : ConversionResult.ERROR;
}
public static boolean checkSingleSymbolLiteral(GroovyPsiElement context) {
final GrLiteral literal = getLiteral(context);
final Object value = literal == null ? null : literal.getValue();
return value == null ? null : value.toString().length() == 1 ? ConversionResult.OK : ConversionResult.ERROR;
return value != null && value.toString().length() == 1;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,6 @@ public class GrNullVoidConverter extends GrTypeConverter {
@Override
public boolean isApplicableTo(@NotNull ApplicableTo position) {
switch (position) {
case EXPLICIT_CAST:
case RETURN_VALUE:
case ASSIGNMENT:
case METHOD_PARAMETER:
@@ -50,22 +49,7 @@ public class GrNullVoidConverter extends GrTypeConverter {
final PsiClassType objectType = TypesUtil.getJavaLangObject(context);
if (currentPosition == ApplicableTo.EXPLICIT_CAST) {
if (PsiType.VOID.equals(TypesUtil.unboxPrimitiveTypeWrapper(targetType))) { // cast to V(v)oid
if (actualType.equals(objectType)) return ConversionResult.WARNING; // cast Object to V(v)oid compiles but fails at runtime
if (PsiType.VOID.equals(targetType)) { // cast to void
// can cast void to void only
return PsiType.VOID.equals(actualType) ? ConversionResult.OK : ConversionResult.ERROR;
}
else { // cast to Void
// can cast Void, void and null to Void
return actualType == PsiType.NULL || PsiType.VOID.equals(TypesUtil.unboxPrimitiveTypeWrapper(actualType))
? ConversionResult.OK
: ConversionResult.ERROR;
}
}
}
else if (currentPosition == ApplicableTo.RETURN_VALUE) {
if (currentPosition == ApplicableTo.RETURN_VALUE) {
if (targetType.equals(objectType) && PsiType.VOID.equals(actualType)) {
return ConversionResult.OK; // can return void from Object
}
@@ -73,8 +57,6 @@ public class GrNullVoidConverter extends GrTypeConverter {
if (PsiType.VOID.equals(actualType)) {
switch (currentPosition) {
case EXPLICIT_CAST:
return ConversionResult.ERROR;
case RETURN_VALUE: {
// we can return void values from method returning enum
if (isEnum(targetType)) return ConversionResult.OK;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@ public class GrNumberConverter extends GrTypeConverter {
@Override
public boolean isApplicableTo(@NotNull ApplicableTo position) {
return position == ApplicableTo.ASSIGNMENT || position == ApplicableTo.EXPLICIT_CAST || position == ApplicableTo.RETURN_VALUE;
return position == ApplicableTo.ASSIGNMENT || position == ApplicableTo.RETURN_VALUE;
}
@Nullable
@@ -0,0 +1,59 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.plugins.groovy.lang.psi.typeEnhancers
import com.intellij.psi.CommonClassNames.JAVA_LANG_OBJECT
import com.intellij.psi.PsiPrimitiveType
import com.intellij.psi.PsiType
import com.intellij.psi.PsiType.*
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.ConversionResult
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.ConversionResult.ERROR
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.ConversionResult.OK
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypeConstants.*
import org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.GrCharConverter.checkSingleSymbolLiteral
class GrPrimitiveCastConverter : GrTypeConverter() {
private companion object {
fun PsiType.unbox() = PsiPrimitiveType.getUnboxedType(this)
val numericRanks = arrayOf(
BYTE_RANK, SHORT_RANK, INTEGER_RANK, LONG_RANK, BIG_INTEGER_RANK, BIG_DECIMAL_RANK, FLOAT_RANK, DOUBLE_RANK
)
}
override fun isApplicableTo(position: ApplicableTo) = position == ApplicableTo.EXPLICIT_CAST
override fun isConvertibleEx(lType: PsiType, rType: PsiType, context: GroovyPsiElement, position: ApplicableTo): ConversionResult? {
if (lType.unbox() == rType) return OK // boxing
if (rType.unbox() == lType) return OK // unboxing
if (rType == VOID) return ERROR
if (lType.equalsToText(JAVA_LANG_OBJECT) || rType.equalsToText(JAVA_LANG_OBJECT)) return OK
if (lType == VOID) return ERROR
if (rType == NULL) return if (lType == BOOLEAN || lType !is PsiPrimitiveType) return OK else ERROR
if (lType.unbox() == VOID || rType.unbox() == VOID) return ERROR
if (lType == BOOLEAN || lType.unbox() == BOOLEAN || rType == BOOLEAN || rType.unbox() == BOOLEAN) return ERROR
if (lType.unbox() == CHAR || rType.unbox() == CHAR) return ERROR
val lRank = getTypeRank(lType)
if (rType == CHAR) return if (lRank in numericRanks) OK else ERROR
val rRank = getTypeRank(rType)
if (lType == CHAR) return if (checkSingleSymbolLiteral(context) || rType is PsiPrimitiveType && rRank in numericRanks) OK else ERROR
return if (lRank in numericRanks && rRank in numericRanks) OK else null
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -115,6 +115,11 @@ class GrReferenceResolveRunner(val place: GrReferenceExpression, val processor:
return processQualifierType(wildcard.extendsBound, state)
}
}
if (qualifierType is PsiWildcardType) {
if (qualifierType.isExtends) {
return processQualifierType(qualifierType.extendsBound, state)
}
}
// Process trait type conjuncts in reversed order because last applied trait matters.
if (qualifierType is GrTraitType) return qualifierType.conjuncts.findLast { !processQualifierType(it, state) } == null
+1
View File
@@ -206,6 +206,7 @@
<typeConverter implementation="org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.GrBooleanTypeConverter"/>
<typeConverter implementation="org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.GrPrimitiveCastConverter"/>
<typeConverter implementation="org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.GrGenericTypeConverter"/>
<typeConverter implementation="org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.GrClassConverter"/>
<typeConverter implementation="org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.GrNullVoidConverter"/>
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,9 +36,7 @@ class GrTypeCheckHighlightingTest extends GrHighlightingTestBase {
void testTypeCheckString() { doTest() }
void testCastToBuiltInPrimitiveTypes() { doTest() }
void testCastToBuiltInBoxedTypes() { doTest() }
void testCastBuiltInTypes() { doTest() }
void doTest() {
addBigDecimal()
@@ -0,0 +1,535 @@
@groovy.transform.CompileStatic
class CastBuiltinTypes {
def castObject(Object _) {
(void) _
(boolean) _
(byte) _
(short) _
(char) _
(int) _
(long) _
(float) _
(double) _
(Void) _
(Boolean) _
(Byte) _
(Short) _
(Character) _
(Integer) _
(Long) _
(Float) _
(Double) _
(BigInteger) _
(BigDecimal) _
(Object) _
}
def castNull() {
<error descr="Cannot cast 'null' to 'void'">(void) null</error>
(boolean) null
<error descr="Cannot cast 'null' to 'byte'">(byte) null</error>
<error descr="Cannot cast 'null' to 'short'">(short) null</error>
<error descr="Cannot cast 'null' to 'char'">(char) null</error>
<error descr="Cannot cast 'null' to 'int'">(int) null</error>
<error descr="Cannot cast 'null' to 'long'">(long) null</error>
<error descr="Cannot cast 'null' to 'float'">(float) null</error>
<error descr="Cannot cast 'null' to 'double'">(double) null</error>
(Void) null
(Boolean) null
(Byte) null
(Short) null
(Character) null
(Integer) null
(Long) null
(Float) null
(Double) null
(BigInteger) null
(BigDecimal) null
(Object) null
}
void foo() {}
def castvoid() {
(void) foo()
<error descr="Cannot cast 'void' to 'boolean'">(boolean) foo()</error>
<error descr="Cannot cast 'void' to 'byte'">(byte) foo()</error>
<error descr="Cannot cast 'void' to 'short'">(short) foo()</error>
<error descr="Cannot cast 'void' to 'char'">(char) foo()</error>
<error descr="Cannot cast 'void' to 'int'">(int) foo()</error>
<error descr="Cannot cast 'void' to 'long'">(long) foo()</error>
<error descr="Cannot cast 'void' to 'float'">(float) foo()</error>
<error descr="Cannot cast 'void' to 'double'">(double) foo()</error>
(Void) foo()
<error descr="Cannot cast 'void' to 'Boolean'">(Boolean) foo()</error>
<error descr="Cannot cast 'void' to 'Byte'">(Byte) foo()</error>
<error descr="Cannot cast 'void' to 'Short'">(Short) foo()</error>
<error descr="Cannot cast 'void' to 'Character'">(Character) foo()</error>
<error descr="Cannot cast 'void' to 'Integer'">(Integer) foo()</error>
<error descr="Cannot cast 'void' to 'Long'">(Long) foo()</error>
<error descr="Cannot cast 'void' to 'Float'">(Float) foo()</error>
<error descr="Cannot cast 'void' to 'Double'">(Double) foo()</error>
<error descr="Cannot cast 'void' to 'BigInteger'">(BigInteger) foo()</error>
<error descr="Cannot cast 'void' to 'BigDecimal'">(BigDecimal) foo()</error>
<error descr="Cannot cast 'void' to 'Object'">(Object) foo()</error>
}
Void bar() {}
def castVoid() {
(void) bar()
<error descr="Cannot cast 'Void' to 'boolean'">(boolean) bar()</error>
<error descr="Cannot cast 'Void' to 'byte'">(byte) bar()</error>
<error descr="Cannot cast 'Void' to 'short'">(short) bar()</error>
<error descr="Cannot cast 'Void' to 'char'">(char) bar()</error>
<error descr="Cannot cast 'Void' to 'int'">(int) bar()</error>
<error descr="Cannot cast 'Void' to 'long'">(long) bar()</error>
<error descr="Cannot cast 'Void' to 'float'">(float) bar()</error>
<error descr="Cannot cast 'Void' to 'double'">(double) bar()</error>
(Void) bar()
<error descr="Cannot cast 'Void' to 'Boolean'">(Boolean) bar()</error>
<error descr="Cannot cast 'Void' to 'Byte'">(Byte) bar()</error>
<error descr="Cannot cast 'Void' to 'Short'">(Short) bar()</error>
<error descr="Cannot cast 'Void' to 'Character'">(Character) bar()</error>
<error descr="Cannot cast 'Void' to 'Integer'">(Integer) bar()</error>
<error descr="Cannot cast 'Void' to 'Long'">(Long) bar()</error>
<error descr="Cannot cast 'Void' to 'Float'">(Float) bar()</error>
<error descr="Cannot cast 'Void' to 'Double'">(Double) bar()</error>
<error descr="Cannot cast 'Void' to 'BigInteger'">(BigInteger) bar()</error>
<error descr="Cannot cast 'Void' to 'BigDecimal'">(BigDecimal) bar()</error>
(Object) bar()
}
def castboolean(boolean _) {
<error descr="Cannot cast 'boolean' to 'void'">(void) _</error>
(boolean) _
<error descr="Cannot cast 'boolean' to 'byte'">(byte) _</error>
<error descr="Cannot cast 'boolean' to 'short'">(short) _</error>
<error descr="Cannot cast 'boolean' to 'char'">(char) _</error>
<error descr="Cannot cast 'boolean' to 'int'">(int) _</error>
<error descr="Cannot cast 'boolean' to 'long'">(long) _</error>
<error descr="Cannot cast 'boolean' to 'float'">(float) _</error>
<error descr="Cannot cast 'boolean' to 'double'">(double) _</error>
<error descr="Cannot cast 'boolean' to 'Void'">(Void) _</error>
(Boolean) _
<error descr="Cannot cast 'boolean' to 'Byte'">(Byte) _</error>
<error descr="Cannot cast 'boolean' to 'Short'">(Short) _</error>
<error descr="Cannot cast 'boolean' to 'Character'">(Character) _</error>
<error descr="Cannot cast 'boolean' to 'Integer'">(Integer) _</error>
<error descr="Cannot cast 'boolean' to 'Long'">(Long) _</error>
<error descr="Cannot cast 'boolean' to 'Float'">(Float) _</error>
<error descr="Cannot cast 'boolean' to 'Double'">(Double) _</error>
<error descr="Cannot cast 'boolean' to 'BigInteger'">(BigInteger) _</error>
<error descr="Cannot cast 'boolean' to 'BigDecimal'">(BigDecimal) _</error>
(Object) _
}
def castBoolean(Boolean _) {
<error descr="Cannot cast 'Boolean' to 'void'">(void) _</error>
(boolean) _
<error descr="Cannot cast 'Boolean' to 'byte'">(byte) _</error>
<error descr="Cannot cast 'Boolean' to 'short'">(short) _</error>
<error descr="Cannot cast 'Boolean' to 'char'">(char) _</error>
<error descr="Cannot cast 'Boolean' to 'int'">(int) _</error>
<error descr="Cannot cast 'Boolean' to 'long'">(long) _</error>
<error descr="Cannot cast 'Boolean' to 'float'">(float) _</error>
<error descr="Cannot cast 'Boolean' to 'double'">(double) _</error>
<error descr="Cannot cast 'Boolean' to 'Void'">(Void) _</error>
(Boolean) _
<error descr="Cannot cast 'Boolean' to 'Byte'">(Byte) _</error>
<error descr="Cannot cast 'Boolean' to 'Short'">(Short) _</error>
<error descr="Cannot cast 'Boolean' to 'Character'">(Character) _</error>
<error descr="Cannot cast 'Boolean' to 'Integer'">(Integer) _</error>
<error descr="Cannot cast 'Boolean' to 'Long'">(Long) _</error>
<error descr="Cannot cast 'Boolean' to 'Float'">(Float) _</error>
<error descr="Cannot cast 'Boolean' to 'Double'">(Double) _</error>
<error descr="Cannot cast 'Boolean' to 'BigInteger'">(BigInteger) _</error>
<error descr="Cannot cast 'Boolean' to 'BigDecimal'">(BigDecimal) _</error>
(Object) _
}
def castCharacter(Character _) {
<error descr="Cannot cast 'Character' to 'void'">(void) _</error>
<error descr="Cannot cast 'Character' to 'boolean'">(boolean) _</error>
<error descr="Cannot cast 'Character' to 'byte'">(byte) _</error>
<error descr="Cannot cast 'Character' to 'short'">(short) _</error>
(char) _
<error descr="Cannot cast 'Character' to 'int'">(int) _</error>
<error descr="Cannot cast 'Character' to 'long'">(long) _</error>
<error descr="Cannot cast 'Character' to 'float'">(float) _</error>
<error descr="Cannot cast 'Character' to 'double'">(double) _</error>
<error descr="Cannot cast 'Character' to 'Void'">(Void) _</error>
<error descr="Cannot cast 'Character' to 'Boolean'">(Boolean) _</error>
<error descr="Cannot cast 'Character' to 'Byte'">(Byte) _</error>
<error descr="Cannot cast 'Character' to 'Short'">(Short) _</error>
(Character) _
<error descr="Cannot cast 'Character' to 'Integer'">(Integer) _</error>
<error descr="Cannot cast 'Character' to 'Long'">(Long) _</error>
<error descr="Cannot cast 'Character' to 'Float'">(Float) _</error>
<error descr="Cannot cast 'Character' to 'Double'">(Double) _</error>
<error descr="Cannot cast 'Character' to 'BigInteger'">(BigInteger) _</error>
<error descr="Cannot cast 'Character' to 'BigDecimal'">(BigDecimal) _</error>
(Object) _
}
def castChar(char _) {
<error descr="Cannot cast 'char' to 'void'">(void) _</error>
<error descr="Cannot cast 'char' to 'boolean'">(boolean) _</error>
(byte) _
(short) _
(char) _
(int) _
(long) _
(float) _
(double) _
<error descr="Cannot cast 'char' to 'Void'">(Void) _</error>
<error descr="Cannot cast 'char' to 'Boolean'">(Boolean) _</error>
(Byte) _
(Short) _
(Character) _
(Integer) _
(Long) _
(Float) _
(Double) _
(BigInteger) _
(BigDecimal) _
(Object) _
}
def castbyte(byte _) {
<error descr="Cannot cast 'byte' to 'void'">(void) _</error>
<error descr="Cannot cast 'byte' to 'boolean'">(boolean) _</error>
(byte) _
(short) _
(char) _
(int) _
(long) _
(float) _
(double) _
<error descr="Cannot cast 'byte' to 'Void'">(Void) _</error>
<error descr="Cannot cast 'byte' to 'Boolean'">(Boolean) _</error>
(Byte) _
(Short) _
<error descr="Cannot cast 'byte' to 'Character'">(Character) _</error>
(Integer) _
(Long) _
(Float) _
(Double) _
(BigInteger) _
(BigDecimal) _
(Object) _
}
def castshort(short _) {
<error descr="Cannot cast 'short' to 'void'">(void) _</error>
<error descr="Cannot cast 'short' to 'boolean'">(boolean) _</error>
(byte) _
(short) _
(char) _
(int) _
(long) _
(float) _
(double) _
<error descr="Cannot cast 'short' to 'Void'">(Void) _</error>
<error descr="Cannot cast 'short' to 'Boolean'">(Boolean) _</error>
(Byte) _
(Short) _
<error descr="Cannot cast 'short' to 'Character'">(Character) _</error>
(Integer) _
(Long) _
(Float) _
(Double) _
(BigInteger) _
(BigDecimal) _
(Object) _
}
def castInt(int _) {
<error descr="Cannot cast 'int' to 'void'">(void) _</error>
<error descr="Cannot cast 'int' to 'boolean'">(boolean) _</error>
(byte) _
(short) _
(char) _
(int) _
(long) _
(float) _
(double) _
<error descr="Cannot cast 'int' to 'Void'">(Void) _</error>
<error descr="Cannot cast 'int' to 'Boolean'">(Boolean) _</error>
(Byte) _
(Short) _
<error descr="Cannot cast 'int' to 'Character'">(Character) _</error>
(Integer) _
(Long) _
(Float) _
(Double) _
(BigInteger) _
(BigDecimal) _
(Object) _
}
def castlong(long _) {
<error descr="Cannot cast 'long' to 'void'">(void) _</error>
<error descr="Cannot cast 'long' to 'boolean'">(boolean) _</error>
(byte) _
(short) _
(char) _
(int) _
(long) _
(float) _
(double) _
<error descr="Cannot cast 'long' to 'Void'">(Void) _</error>
<error descr="Cannot cast 'long' to 'Boolean'">(Boolean) _</error>
(Byte) _
(Short) _
<error descr="Cannot cast 'long' to 'Character'">(Character) _</error>
(Integer) _
(Long) _
(Float) _
(Double) _
(BigInteger) _
(BigDecimal) _
(Object) _
}
def castfloat(float _) {
<error descr="Cannot cast 'float' to 'void'">(void) _</error>
<error descr="Cannot cast 'float' to 'boolean'">(boolean) _</error>
(byte) _
(short) _
(char) _
(int) _
(long) _
(float) _
(double) _
<error descr="Cannot cast 'float' to 'Void'">(Void) _</error>
<error descr="Cannot cast 'float' to 'Boolean'">(Boolean) _</error>
(Byte) _
(Short) _
<error descr="Cannot cast 'float' to 'Character'">(Character) _</error>
(Integer) _
(Long) _
(Float) _
(Double) _
(BigInteger) _
(BigDecimal) _
(Object) _
}
def castdouble(double _) {
<error descr="Cannot cast 'double' to 'void'">(void) _</error>
<error descr="Cannot cast 'double' to 'boolean'">(boolean) _</error>
(byte) _
(short) _
(char) _
(int) _
(long) _
(float) _
(double) _
<error descr="Cannot cast 'double' to 'Void'">(Void) _</error>
<error descr="Cannot cast 'double' to 'Boolean'">(Boolean) _</error>
(Byte) _
(Short) _
<error descr="Cannot cast 'double' to 'Character'">(Character) _</error>
(Integer) _
(Long) _
(Float) _
(Double) _
(BigInteger) _
(BigDecimal) _
(Object) _
}
def castByte(Byte _) {
<error descr="Cannot cast 'Byte' to 'void'">(void) _</error>
<error descr="Cannot cast 'Byte' to 'boolean'">(boolean) _</error>
(byte) _
(short) _
<error descr="Cannot cast 'Byte' to 'char'">(char) _</error>
(int) _
(long) _
(float) _
(double) _
<error descr="Cannot cast 'Byte' to 'Void'">(Void) _</error>
<error descr="Cannot cast 'Byte' to 'Boolean'">(Boolean) _</error>
(Byte) _
(Short) _
<error descr="Cannot cast 'Byte' to 'Character'">(Character) _</error>
(Integer) _
(Long) _
(Float) _
(Double) _
(BigInteger) _
(BigDecimal) _
(Object) _
}
def castShort(Short _) {
<error descr="Cannot cast 'Short' to 'void'">(void) _</error>
<error descr="Cannot cast 'Short' to 'boolean'">(boolean) _</error>
(byte) _
(short) _
<error descr="Cannot cast 'Short' to 'char'">(char) _</error>
(int) _
(long) _
(float) _
(double) _
<error descr="Cannot cast 'Short' to 'Void'">(Void) _</error>
<error descr="Cannot cast 'Short' to 'Boolean'">(Boolean) _</error>
(Byte) _
(Short) _
<error descr="Cannot cast 'Short' to 'Character'">(Character) _</error>
(Integer) _
(Long) _
(Float) _
(Double) _
(BigInteger) _
(BigDecimal) _
(Object) _
}
def castInteger(Integer _) {
<error descr="Cannot cast 'Integer' to 'void'">(void) _</error>
<error descr="Cannot cast 'Integer' to 'boolean'">(boolean) _</error>
(byte) _
(short) _
<error descr="Cannot cast 'Integer' to 'char'">(char) _</error>
(int) _
(long) _
(float) _
(double) _
<error descr="Cannot cast 'Integer' to 'Void'">(Void) _</error>
<error descr="Cannot cast 'Integer' to 'Boolean'">(Boolean) _</error>
(Byte) _
(Short) _
<error descr="Cannot cast 'Integer' to 'Character'">(Character) _</error>
(Integer) _
(Long) _
(Float) _
(Double) _
(BigInteger) _
(BigDecimal) _
(Object) _
}
def castLong(Long _) {
<error descr="Cannot cast 'Long' to 'void'">(void) _</error>
<error descr="Cannot cast 'Long' to 'boolean'">(boolean) _</error>
(byte) _
(short) _
<error descr="Cannot cast 'Long' to 'char'">(char) _</error>
(int) _
(long) _
(float) _
(double) _
<error descr="Cannot cast 'Long' to 'Void'">(Void) _</error>
<error descr="Cannot cast 'Long' to 'Boolean'">(Boolean) _</error>
(Byte) _
(Short) _
<error descr="Cannot cast 'Long' to 'Character'">(Character) _</error>
(Integer) _
(Long) _
(Float) _
(Double) _
(BigInteger) _
(BigDecimal) _
(Object) _
}
def castFloat(Float _) {
<error descr="Cannot cast 'Float' to 'void'">(void) _</error>
<error descr="Cannot cast 'Float' to 'boolean'">(boolean) _</error>
(byte) _
(short) _
<error descr="Cannot cast 'Float' to 'char'">(char) _</error>
(int) _
(long) _
(float) _
(double) _
<error descr="Cannot cast 'Float' to 'Void'">(Void) _</error>
<error descr="Cannot cast 'Float' to 'Boolean'">(Boolean) _</error>
(Byte) _
(Short) _
<error descr="Cannot cast 'Float' to 'Character'">(Character) _</error>
(Integer) _
(Long) _
(Float) _
(Double) _
(BigInteger) _
(BigDecimal) _
(Object) _
}
def castDouble(Double _) {
<error descr="Cannot cast 'Double' to 'void'">(void) _</error>
<error descr="Cannot cast 'Double' to 'boolean'">(boolean) _</error>
(byte) _
(short) _
<error descr="Cannot cast 'Double' to 'char'">(char) _</error>
(int) _
(long) _
(float) _
(double) _
<error descr="Cannot cast 'Double' to 'Void'">(Void) _</error>
<error descr="Cannot cast 'Double' to 'Boolean'">(Boolean) _</error>
(Byte) _
(Short) _
<error descr="Cannot cast 'Double' to 'Character'">(Character) _</error>
(Integer) _
(Long) _
(Float) _
(Double) _
(BigInteger) _
(BigDecimal) _
(Object) _
}
def castBigInteger(BigInteger _) {
<error descr="Cannot cast 'BigInteger' to 'void'">(void) _</error>
<error descr="Cannot cast 'BigInteger' to 'boolean'">(boolean) _</error>
(byte) _
(short) _
<error descr="Cannot cast 'BigInteger' to 'char'">(char) _</error>
(int) _
(long) _
(float) _
(double) _
<error descr="Cannot cast 'BigInteger' to 'Void'">(Void) _</error>
<error descr="Cannot cast 'BigInteger' to 'Boolean'">(Boolean) _</error>
(Byte) _
(Short) _
<error descr="Cannot cast 'BigInteger' to 'Character'">(Character) _</error>
(Integer) _
(Long) _
(Float) _
(Double) _
(BigInteger) _
(BigDecimal) _
(Object) _
}
def castBigDecimal(BigDecimal _) {
<error descr="Cannot cast 'BigDecimal' to 'void'">(void) _</error>
<error descr="Cannot cast 'BigDecimal' to 'boolean'">(boolean) _</error>
(byte) _
(short) _
<error descr="Cannot cast 'BigDecimal' to 'char'">(char) _</error>
(int) _
(long) _
(float) _
(double) _
<error descr="Cannot cast 'BigDecimal' to 'Void'">(Void) _</error>
<error descr="Cannot cast 'BigDecimal' to 'Boolean'">(Boolean) _</error>
(Byte) _
(Short) _
<error descr="Cannot cast 'BigDecimal' to 'Character'">(Character) _</error>
(Integer) _
(Long) _
(Float) _
(Double) _
(BigInteger) _
(BigDecimal) _
(Object) _
}
}
@@ -1,280 +0,0 @@
import groovy.transform.CompileStatic
@CompileStatic
class FooCastToBuiltinBoxedTypes {
def castToVoidB() {
(Void) null
(Void) 1 as void
<error descr="Cannot cast 'boolean' to 'Void'">(Void) 1 as boolean</error>
<error descr="Cannot cast 'byte' to 'Void'">(Void) 1 as byte</error>
<error descr="Cannot cast 'short' to 'Void'">(Void) 1 as short</error>
<error descr="Cannot cast 'char' to 'Void'">(Void) 1 as char</error>
<error descr="Cannot cast 'int' to 'Void'">(Void) 1 as int</error>
<error descr="Cannot cast 'long' to 'Void'">(Void) 1 as long</error>
<error descr="Cannot cast 'float' to 'Void'">(Void) 1 as float</error>
<error descr="Cannot cast 'double' to 'Void'">(Void) 1 as double</error>
<error descr="Cannot cast 'BigInteger' to 'Void'">(Void) 1 as BigInteger</error>
<error descr="Cannot cast 'BigDecimal' to 'Void'">(Void) 1 as BigDecimal</error>
(Void) 1 as Void
<error descr="Cannot cast 'Boolean' to 'Void'">(Void) 1 as Boolean</error>
<error descr="Cannot cast 'Byte' to 'Void'">(Void) 1 as Byte</error>
<error descr="Cannot cast 'Short' to 'Void'">(Void) 1 as Short</error>
<error descr="Cannot cast 'Character' to 'Void'">(Void) 1 as Character</error>
<error descr="Cannot cast 'Integer' to 'Void'">(Void) 1 as Integer</error>
<error descr="Cannot cast 'Long' to 'Void'">(Void) 1 as Long</error>
<error descr="Cannot cast 'Float' to 'Void'">(Void) 1 as Float</error>
<error descr="Cannot cast 'Double' to 'Void'">(Void) 1 as Double</error>
<warning descr="Cannot cast 'Object' to 'Void'">(Void) 1 as Object</warning>
}
def castToBigInteger() {
(BigInteger) null
<error descr="Cannot cast 'void' to 'BigInteger'">(BigInteger) 1 as void</error>
<error descr="Cannot cast 'boolean' to 'BigInteger'">(BigInteger) 1 as boolean</error>
(BigInteger) 1 as byte
(BigInteger) 1 as short
(BigInteger) 1 as char
(BigInteger) 1 as int
(BigInteger) 1 as long
(BigInteger) 1 as float
(BigInteger) 1 as double
(BigInteger) 1 as BigInteger
(BigInteger) 1 as BigDecimal
<error descr="Cannot cast 'Void' to 'BigInteger'">(BigInteger) 1 as Void</error>
<error descr="Cannot cast 'Boolean' to 'BigInteger'">(BigInteger) 1 as Boolean</error>
(BigInteger) 1 as Byte
(BigInteger) 1 as Short
<error descr="Cannot cast 'Character' to 'BigInteger'">(BigInteger) 1 as Character</error>
(BigInteger) 1 as Integer
(BigInteger) 1 as Long
(BigInteger) 1 as Float
(BigInteger) 1 as Double
(BigInteger) 1 as Object
}
def castToBigDecimal() {
(BigDecimal) null
<error descr="Cannot cast 'void' to 'BigDecimal'">(BigDecimal) 1 as void</error>
<error descr="Cannot cast 'boolean' to 'BigDecimal'">(BigDecimal) 1 as boolean</error>
(BigDecimal) 1 as byte
(BigDecimal) 1 as short
(BigDecimal) 1 as char
(BigDecimal) 1 as int
(BigDecimal) 1 as long
(BigDecimal) 1 as float
(BigDecimal) 1 as double
(BigDecimal) 1 as BigInteger
(BigDecimal) 1 as BigDecimal
<error descr="Cannot cast 'Void' to 'BigDecimal'">(BigDecimal) 1 as Void</error>
<error descr="Cannot cast 'Boolean' to 'BigDecimal'">(BigDecimal) 1 as Boolean</error>
(BigDecimal) 1 as Byte
(BigDecimal) 1 as Short
<error descr="Cannot cast 'Character' to 'BigDecimal'">(BigDecimal) 1 as Character</error>
(BigDecimal) 1 as Integer
(BigDecimal) 1 as Long
(BigDecimal) 1 as Float
(BigDecimal) 1 as Double
(BigDecimal) 1 as Object
}
def castToBoolean() {
(Boolean) null
<error descr="Cannot cast 'void' to 'Boolean'">(Boolean) 1 as void</error>
(Boolean) 1 as boolean
<error descr="Cannot cast 'byte' to 'Boolean'">(Boolean) 1 as byte</error>
<error descr="Cannot cast 'short' to 'Boolean'">(Boolean) 1 as short</error>
<error descr="Cannot cast 'char' to 'Boolean'">(Boolean) 1 as char</error>
<error descr="Cannot cast 'int' to 'Boolean'">(Boolean) 1 as int</error>
<error descr="Cannot cast 'long' to 'Boolean'">(Boolean) 1 as long</error>
<error descr="Cannot cast 'float' to 'Boolean'">(Boolean) 1 as float</error>
<error descr="Cannot cast 'double' to 'Boolean'">(Boolean) 1 as double</error>
<error descr="Cannot cast 'BigInteger' to 'Boolean'">(Boolean) 1 as BigInteger</error>
<error descr="Cannot cast 'BigDecimal' to 'Boolean'">(Boolean) 1 as BigDecimal</error>
<error descr="Cannot cast 'Void' to 'Boolean'">(Boolean) 1 as Void</error>
(Boolean) 1 as Boolean
<error descr="Cannot cast 'Byte' to 'Boolean'">(Boolean) 1 as Byte</error>
<error descr="Cannot cast 'Short' to 'Boolean'">(Boolean) 1 as Short</error>
<error descr="Cannot cast 'Character' to 'Boolean'">(Boolean) 1 as Character</error>
<error descr="Cannot cast 'Integer' to 'Boolean'">(Boolean) 1 as Integer</error>
<error descr="Cannot cast 'Long' to 'Boolean'">(Boolean) 1 as Long</error>
<error descr="Cannot cast 'Float' to 'Boolean'">(Boolean) 1 as Float</error>
<error descr="Cannot cast 'Double' to 'Boolean'">(Boolean) 1 as Double</error>
(Boolean) 1 as Object
}
def castToByte() {
(Byte) null
<error descr="Cannot cast 'void' to 'Byte'">(Byte) 1 as void</error>
<error descr="Cannot cast 'boolean' to 'Byte'">(Byte) 1 as boolean</error>
(Byte) 1 as byte
(Byte) 1 as short
(Byte) 1 as char
(Byte) 1 as int
(Byte) 1 as long
(Byte) 1 as float
(Byte) 1 as double
(Byte) 1 as BigInteger
(Byte) 1 as BigDecimal
<error descr="Cannot cast 'Void' to 'Byte'">(Byte) 1 as Void</error>
<error descr="Cannot cast 'Boolean' to 'Byte'">(Byte) 1 as Boolean</error>
(Byte) 1 as Byte
(Byte) 1 as Short
<error descr="Cannot cast 'Character' to 'Byte'">(Byte) 1 as Character</error>
(Byte) 1 as Integer
(Byte) 1 as Long
(Byte) 1 as Float
(Byte) 1 as Double
(Byte) 1 as Object
}
def castToShort() {
(Short) null
<error descr="Cannot cast 'void' to 'Short'">(Short) 1 as void</error>
<error descr="Cannot cast 'boolean' to 'Short'">(Short) 1 as boolean</error>
(Short) 1 as byte
(Short) 1 as short
(Short) 1 as char
(Short) 1 as int
(Short) 1 as long
(Short) 1 as float
(Short) 1 as double
(Short) 1 as BigInteger
(Short) 1 as BigDecimal
<error descr="Cannot cast 'Void' to 'Short'">(Short) 1 as Void</error>
<error descr="Cannot cast 'Boolean' to 'Short'">(Short) 1 as Boolean</error>
(Short) 1 as Byte
(Short) 1 as Short
<error descr="Cannot cast 'Character' to 'Short'">(Short) 1 as Character</error>
(Short) 1 as Integer
(Short) 1 as Long
(Short) 1 as Float
(Short) 1 as Double
(Short) 1 as Object
}
def castToChar() {
(Character) null
<error descr="Cannot cast 'void' to 'Character'">(Character) 1 as void</error>
<error descr="Cannot cast 'boolean' to 'Character'">(Character) 1 as boolean</error>
<error descr="Cannot cast 'byte' to 'Character'">(Character) 1 as byte</error>
<error descr="Cannot cast 'short' to 'Character'">(Character) 1 as short</error>
(Character) 1 as char
<error descr="Cannot cast 'int' to 'Character'">(Character) 1 as int</error>
<error descr="Cannot cast 'long' to 'Character'">(Character) 1 as long</error>
<error descr="Cannot cast 'float' to 'Character'">(Character) 1 as float</error>
<error descr="Cannot cast 'double' to 'Character'">(Character) 1 as double</error>
<error descr="Cannot cast 'BigInteger' to 'Character'">(Character) 1 as BigInteger</error>
<error descr="Cannot cast 'BigDecimal' to 'Character'">(Character) 1 as BigDecimal</error>
<error descr="Cannot cast 'Void' to 'Character'">(Character) 1 as Void</error>
<error descr="Cannot cast 'Boolean' to 'Character'">(Character) 1 as Boolean</error>
<error descr="Cannot cast 'Byte' to 'Character'">(Character) 1 as Byte</error>
<error descr="Cannot cast 'Short' to 'Character'">(Character) 1 as Short</error>
(Character) 1 as Character
<error descr="Cannot cast 'Integer' to 'Character'">(Character) 1 as Integer</error>
<error descr="Cannot cast 'Long' to 'Character'">(Character) 1 as Long</error>
<error descr="Cannot cast 'Float' to 'Character'">(Character) 1 as Float</error>
<error descr="Cannot cast 'Double' to 'Character'">(Character) 1 as Double</error>
(Character) 1 as Object
}
def castToInt() {
(Integer) null
<error descr="Cannot cast 'void' to 'Integer'">(Integer) 1 as void</error>
<error descr="Cannot cast 'boolean' to 'Integer'">(Integer) 1 as boolean</error>
(Integer) 1 as byte
(Integer) 1 as short
(Integer) 1 as char
(Integer) 1 as int
(Integer) 1 as long
(Integer) 1 as float
(Integer) 1 as double
(Integer) 1 as BigInteger
(Integer) 1 as BigDecimal
<error descr="Cannot cast 'Void' to 'Integer'">(Integer) 1 as Void</error>
<error descr="Cannot cast 'Boolean' to 'Integer'">(Integer) 1 as Boolean</error>
(Integer) 1 as Byte
(Integer) 1 as Short
<error descr="Cannot cast 'Character' to 'Integer'">(Integer) 1 as Character</error>
(Integer) 1 as Integer
(Integer) 1 as Long
(Integer) 1 as Float
(Integer) 1 as Double
(Integer) 1 as Object
}
def castToLong() {
(Long) null
<error descr="Cannot cast 'void' to 'Long'">(Long) 1 as void</error>
<error descr="Cannot cast 'boolean' to 'Long'">(Long) 1 as boolean</error>
(Long) 1 as byte
(Long) 1 as short
(Long) 1 as char
(Long) 1 as int
(Long) 1 as long
(Long) 1 as float
(Long) 1 as double
(Long) 1 as BigInteger
(Long) 1 as BigDecimal
<error descr="Cannot cast 'Void' to 'Long'">(Long) 1 as Void</error>
<error descr="Cannot cast 'Boolean' to 'Long'">(Long) 1 as Boolean</error>
(Long) 1 as Byte
(Long) 1 as Short
<error descr="Cannot cast 'Character' to 'Long'">(Long) 1 as Character</error>
(Long) 1 as Integer
(Long) 1 as Long
(Long) 1 as Float
(Long) 1 as Double
(Long) 1 as Object
}
def castToFloat() {
(Float) null
<error descr="Cannot cast 'void' to 'Float'">(Float) 1 as void</error>
<error descr="Cannot cast 'boolean' to 'Float'">(Float) 1 as boolean</error>
(Float) 1 as byte
(Float) 1 as short
(Float) 1 as char
(Float) 1 as int
(Float) 1 as long
(Float) 1 as float
(Float) 1 as double
(Float) 1 as BigInteger
(Float) 1 as BigDecimal
<error descr="Cannot cast 'Void' to 'Float'">(Float) 1 as Void</error>
<error descr="Cannot cast 'Boolean' to 'Float'">(Float) 1 as Boolean</error>
(Float) 1 as Byte
(Float) 1 as Short
<error descr="Cannot cast 'Character' to 'Float'">(Float) 1 as Character</error>
(Float) 1 as Integer
(Float) 1 as Long
(Float) 1 as Float
(Float) 1 as Double
(Float) 1 as Object
}
def castToDouble() {
(Double) null
<error descr="Cannot cast 'void' to 'Double'">(Double) 1 as void</error>
<error descr="Cannot cast 'boolean' to 'Double'">(Double) 1 as boolean</error>
(Double) 1 as byte
(Double) 1 as short
(Double) 1 as char
(Double) 1 as int
(Double) 1 as long
(Double) 1 as float
(Double) 1 as double
(Double) 1 as BigInteger
(Double) 1 as BigDecimal
<error descr="Cannot cast 'Void' to 'Double'">(Double) 1 as Void</error>
<error descr="Cannot cast 'Boolean' to 'Double'">(Double) 1 as Boolean</error>
(Double) 1 as Byte
(Double) 1 as Short
<error descr="Cannot cast 'Character' to 'Double'">(Double) 1 as Character</error>
(Double) 1 as Integer
(Double) 1 as Long
(Double) 1 as Float
(Double) 1 as Double
(Double) 1 as Object
}
}
@@ -1,230 +0,0 @@
import groovy.transform.CompileStatic
@CompileStatic
class FooCastToBuiltinPrimitiveTypes {
def castToVoid() {
<error descr="Cannot cast 'null' to 'void'">(void) null</error>
(void) 1 as void // no error, can cast void to void
<error descr="Cannot cast 'boolean' to 'void'">(void) 1 as boolean</error>
<error descr="Cannot cast 'byte' to 'void'">(void) 1 as byte</error>
<error descr="Cannot cast 'short' to 'void'">(void) 1 as short</error>
<error descr="Cannot cast 'char' to 'void'">(void) 1 as char</error>
<error descr="Cannot cast 'int' to 'void'">(void) 1 as int</error>
<error descr="Cannot cast 'long' to 'void'">(void) 1 as long</error>
<error descr="Cannot cast 'float' to 'void'">(void) 1 as float</error>
<error descr="Cannot cast 'double' to 'void'">(void) 1 as double</error>
<error descr="Cannot cast 'BigInteger' to 'void'">(void) 1 as BigInteger</error>
<error descr="Cannot cast 'BigDecimal' to 'void'">(void) 1 as BigDecimal</error>
<error descr="Cannot cast 'Void' to 'void'">(void) 1 as Void</error>
<error descr="Cannot cast 'Boolean' to 'void'">(void) 1 as Boolean</error>
<error descr="Cannot cast 'Byte' to 'void'">(void) 1 as Byte</error>
<error descr="Cannot cast 'Short' to 'void'">(void) 1 as Short</error>
<error descr="Cannot cast 'Character' to 'void'">(void) 1 as Character</error>
<error descr="Cannot cast 'Integer' to 'void'">(void) 1 as Integer</error>
<error descr="Cannot cast 'Long' to 'void'">(void) 1 as Long</error>
<error descr="Cannot cast 'Float' to 'void'">(void) 1 as Float</error>
<error descr="Cannot cast 'Double' to 'void'">(void) 1 as Double</error>
<warning descr="Cannot cast 'Object' to 'void'">(void) 1 as Object</warning> // no compile time, but will be runtime error
}
def castToBoolean() {
(boolean) null
<error descr="Cannot cast 'void' to 'boolean'">(boolean) 1 as void</error>
(boolean) 1 as boolean
<error descr="Cannot cast 'byte' to 'boolean'">(boolean) 1 as byte</error>
<error descr="Cannot cast 'short' to 'boolean'">(boolean) 1 as short</error>
<error descr="Cannot cast 'char' to 'boolean'">(boolean) 1 as char</error>
<error descr="Cannot cast 'int' to 'boolean'">(boolean) 1 as int</error>
<error descr="Cannot cast 'long' to 'boolean'">(boolean) 1 as long</error>
<error descr="Cannot cast 'float' to 'boolean'">(boolean) 1 as float</error>
<error descr="Cannot cast 'double' to 'boolean'">(boolean) 1 as double</error>
<error descr="Cannot cast 'BigInteger' to 'boolean'">(boolean) 1 as BigInteger</error>
<error descr="Cannot cast 'BigDecimal' to 'boolean'">(boolean) 1 as BigDecimal</error>
<error descr="Cannot cast 'Void' to 'boolean'">(boolean) 1 as Void</error>
(boolean) 1 as Boolean
<error descr="Cannot cast 'Byte' to 'boolean'">(boolean) 1 as Byte</error>
<error descr="Cannot cast 'Short' to 'boolean'">(boolean) 1 as Short</error>
<error descr="Cannot cast 'Character' to 'boolean'">(boolean) 1 as Character</error>
<error descr="Cannot cast 'Integer' to 'boolean'">(boolean) 1 as Integer</error>
<error descr="Cannot cast 'Long' to 'boolean'">(boolean) 1 as Long</error>
<error descr="Cannot cast 'Float' to 'boolean'">(boolean) 1 as Float</error>
<error descr="Cannot cast 'Double' to 'boolean'">(boolean) 1 as Double</error>
(boolean) 1 as Object
}
def castToByte() {
<error descr="Cannot cast 'null' to 'byte'">(byte) null</error>
<error descr="Cannot cast 'void' to 'byte'">(byte) 1 as void</error>
<error descr="Cannot cast 'boolean' to 'byte'">(byte) 1 as boolean</error>
(byte) 1 as byte
(byte) 1 as short
(byte) 1 as char
(byte) 1 as int
(byte) 1 as long
(byte) 1 as float
(byte) 1 as double
(byte) 1 as BigInteger
(byte) 1 as BigDecimal
<error descr="Cannot cast 'Void' to 'byte'">(byte) 1 as Void</error>
<error descr="Cannot cast 'Boolean' to 'byte'">(byte) 1 as Boolean</error>
(byte) 1 as Byte
(byte) 1 as Short
<error descr="Cannot cast 'Character' to 'byte'">(byte) 1 as Character</error>
(byte) 1 as Integer
(byte) 1 as Long
(byte) 1 as Float
(byte) 1 as Double
(byte) 1 as Object
}
def castToShort() {
<error descr="Cannot cast 'null' to 'short'">(short) null</error>
<error descr="Cannot cast 'void' to 'short'">(short) 1 as void</error>
<error descr="Cannot cast 'boolean' to 'short'">(short) 1 as boolean</error>
(short) 1 as byte
(short) 1 as short
(short) 1 as char
(short) 1 as int
(short) 1 as long
(short) 1 as float
(short) 1 as double
(short) 1 as BigInteger
(short) 1 as BigDecimal
<error descr="Cannot cast 'Void' to 'short'">(short) 1 as Void</error>
<error descr="Cannot cast 'Boolean' to 'short'">(short) 1 as Boolean</error>
(short) 1 as Byte
(short) 1 as Short
<error descr="Cannot cast 'Character' to 'short'">(short) 1 as Character</error>
(short) 1 as Integer
(short) 1 as Long
(short) 1 as Float
(short) 1 as Double
(short) 1 as Object
}
def castToChar() {
<error descr="Cannot cast 'null' to 'char'">(char) null</error>
<error descr="Cannot cast 'void' to 'char'">(char) 1 as void</error>
<error descr="Cannot cast 'boolean' to 'char'">(char) 1 as boolean</error>
(char) 1 as byte
(char) 1 as short
(char) 1 as char
(char) 1 as int
(char) 1 as long
(char) 1 as float
(char) 1 as double
<error descr="Cannot cast 'BigInteger' to 'char'">(char) 1 as BigInteger</error>
<error descr="Cannot cast 'BigDecimal' to 'char'">(char) 1 as BigDecimal</error>
<error descr="Cannot cast 'Void' to 'char'">(char) 1 as Void</error>
<error descr="Cannot cast 'Boolean' to 'char'">(char) 1 as Boolean</error>
<error descr="Cannot cast 'Byte' to 'char'">(char) 1 as Byte</error>
<error descr="Cannot cast 'Short' to 'char'">(char) 1 as Short</error>
(char) 1 as Character
<error descr="Cannot cast 'Integer' to 'char'">(char) 1 as Integer</error>
<error descr="Cannot cast 'Long' to 'char'">(char) 1 as Long</error>
<error descr="Cannot cast 'Float' to 'char'">(char) 1 as Float</error>
<error descr="Cannot cast 'Double' to 'char'">(char) 1 as Double</error>
(char) 1 as Object
}
def castToInt() {
<error descr="Cannot cast 'null' to 'int'">(int) null</error>
<error descr="Cannot cast 'void' to 'int'">(int) 1 as void</error>
<error descr="Cannot cast 'boolean' to 'int'">(int) 1 as boolean</error>
(int) 1 as byte
(int) 1 as short
(int) 1 as char
(int) 1 as int
(int) 1 as long
(int) 1 as float
(int) 1 as double
(int) 1 as BigInteger
(int) 1 as BigDecimal
<error descr="Cannot cast 'Void' to 'int'">(int) 1 as Void</error>
<error descr="Cannot cast 'Boolean' to 'int'">(int) 1 as Boolean</error>
(int) 1 as Byte
(int) 1 as Short
<error descr="Cannot cast 'Character' to 'int'">(int) 1 as Character</error>
(int) 1 as Integer
(int) 1 as Long
(int) 1 as Float
(int) 1 as Double
(int) 1 as Object
}
def castToLong() {
<error descr="Cannot cast 'null' to 'long'">(long) null</error>
<error descr="Cannot cast 'void' to 'long'">(long) 1 as void</error>
<error descr="Cannot cast 'boolean' to 'long'">(long) 1 as boolean</error>
(long) 1 as byte
(long) 1 as short
(long) 1 as char
(long) 1 as int
(long) 1 as long
(long) 1 as float
(long) 1 as double
(long) 1 as BigInteger
(long) 1 as BigDecimal
<error descr="Cannot cast 'Void' to 'long'">(long) 1 as Void</error>
<error descr="Cannot cast 'Boolean' to 'long'">(long) 1 as Boolean</error>
(long) 1 as Byte
(long) 1 as Short
<error descr="Cannot cast 'Character' to 'long'">(long) 1 as Character</error>
(long) 1 as Integer
(long) 1 as Long
(long) 1 as Float
(long) 1 as Double
(long) 1 as Object
}
def castToFloat() {
<error descr="Cannot cast 'null' to 'float'">(float) null</error>
<error descr="Cannot cast 'void' to 'float'">(float) 1 as void</error>
<error descr="Cannot cast 'boolean' to 'float'">(float) 1 as boolean</error>
(float) 1 as byte
(float) 1 as short
(float) 1 as char
(float) 1 as int
(float) 1 as long
(float) 1 as float
(float) 1 as double
(float) 1 as BigInteger
(float) 1 as BigDecimal
<error descr="Cannot cast 'Void' to 'float'">(float) 1 as Void</error>
<error descr="Cannot cast 'Boolean' to 'float'">(float) 1 as Boolean</error>
(float) 1 as Byte
(float) 1 as Short
<error descr="Cannot cast 'Character' to 'float'">(float) 1 as Character</error>
(float) 1 as Integer
(float) 1 as Long
(float) 1 as Float
(float) 1 as Double
(float) 1 as Object
}
def castToDouble() {
<error descr="Cannot cast 'null' to 'double'">(double) null</error>
<error descr="Cannot cast 'void' to 'double'">(double) 1 as void</error>
<error descr="Cannot cast 'boolean' to 'double'">(double) 1 as boolean</error>
(double) 1 as byte
(double) 1 as short
(double) 1 as char
(double) 1 as int
(double) 1 as long
(double) 1 as float
(double) 1 as double
(double) 1 as BigInteger
(double) 1 as BigDecimal
<error descr="Cannot cast 'Void' to 'double'">(double) 1 as Void</error>
<error descr="Cannot cast 'Boolean' to 'double'">(double) 1 as Boolean</error>
(double) 1 as Byte
(double) 1 as Short
<error descr="Cannot cast 'Character' to 'double'">(double) 1 as Character</error>
(double) 1 as Integer
(double) 1 as Long
(double) 1 as Float
(double) 1 as Double
(double) 1 as Object
}
}