mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#312 fix ClassCastException in Eclipse JDT compiler when trying to compute the erasure of the 'void' type, extend integration test that reproduced the error
This commit is contained in:
parent
4d408d5560
commit
54b8747e09
@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* contributors.
|
||||||
|
*
|
||||||
|
* 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.mapstruct.itest.simple;
|
||||||
|
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
|
import org.mapstruct.Mappings;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public abstract class SourceTargetAbstractMapper {
|
||||||
|
|
||||||
|
public static SourceTargetAbstractMapper INSTANCE = Mappers.getMapper( SourceTargetAbstractMapper.class );
|
||||||
|
|
||||||
|
@Mappings({
|
||||||
|
@Mapping(source = "qax", target = "baz"),
|
||||||
|
@Mapping(source = "baz", target = "qax")
|
||||||
|
})
|
||||||
|
public abstract Target sourceToTarget(Source source);
|
||||||
|
|
||||||
|
public abstract Source targetToSource(Target target);
|
||||||
|
|
||||||
|
protected void isNeverCalled(Source source) {
|
||||||
|
throw new RuntimeException("not expected to be called");
|
||||||
|
}
|
||||||
|
}
|
@ -93,4 +93,19 @@ public class ConversionTest {
|
|||||||
assertThat( source.getBaz() ).isEqualTo( 42 );
|
assertThat( source.getBaz() ).isEqualTo( 42 );
|
||||||
assertThat( source.getQax() ).isEqualTo( 23 );
|
assertThat( source.getQax() ).isEqualTo( 23 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldWorkWithAbstractClass() {
|
||||||
|
Source source = new Source();
|
||||||
|
source.setFoo( 42 );
|
||||||
|
source.setBar( 23L );
|
||||||
|
source.setZip( 73 );
|
||||||
|
|
||||||
|
Target target = SourceTargetAbstractMapper.INSTANCE.sourceToTarget( source );
|
||||||
|
|
||||||
|
assertThat( target ).isNotNull();
|
||||||
|
assertThat( target.getFoo() ).isEqualTo( Long.valueOf( 42 ) );
|
||||||
|
assertThat( target.getBar() ).isEqualTo( 23 );
|
||||||
|
assertThat( target.getZip() ).isEqualTo( "73" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ public class Type extends ModelElement implements Comparable<Type> {
|
|||||||
this.isCollectionType = isCollectionType;
|
this.isCollectionType = isCollectionType;
|
||||||
this.isMapType = isMapType;
|
this.isMapType = isMapType;
|
||||||
this.isImported = isImported;
|
this.isImported = isImported;
|
||||||
this.isVoid = typeMirror.getKind().equals( TypeKind.VOID );
|
this.isVoid = typeMirror.getKind() == TypeKind.VOID;
|
||||||
|
|
||||||
if ( isEnumType ) {
|
if ( isEnumType ) {
|
||||||
enumConstants = new ArrayList<String>();
|
enumConstants = new ArrayList<String>();
|
||||||
|
@ -123,9 +123,10 @@ public class TypeFactory {
|
|||||||
|
|
||||||
Type implementationType = getImplementationType( mirror );
|
Type implementationType = getImplementationType( mirror );
|
||||||
|
|
||||||
boolean isIterableType = TypeUtilsJDK6Fix.isSubType( typeUtils, mirror, iterableType );
|
boolean isVoid = mirror.getKind() == TypeKind.VOID;
|
||||||
boolean isCollectionType = TypeUtilsJDK6Fix.isSubType( typeUtils, mirror, collectionType );
|
boolean isIterableType = !isVoid && TypeUtilsJDK6Fix.isSubType( typeUtils, mirror, iterableType );
|
||||||
boolean isMapType = TypeUtilsJDK6Fix.isSubType( typeUtils, mirror, mapType );
|
boolean isCollectionType = !isVoid && TypeUtilsJDK6Fix.isSubType( typeUtils, mirror, collectionType );
|
||||||
|
boolean isMapType = !isVoid && TypeUtilsJDK6Fix.isSubType( typeUtils, mirror, mapType );
|
||||||
|
|
||||||
boolean isEnumType;
|
boolean isEnumType;
|
||||||
boolean isInterface;
|
boolean isInterface;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user