Skip to content

Commit b37b0b4

Browse files
authored
Fix missing validation for Optional type parameters in Embeddable properties (#1399)
2 parents 15db8a7 + 2832172 commit b37b0b4

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

doma-processor/src/main/java/org/seasar/doma/internal/apt/meta/entity/EmbeddablePropertyMetaFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public Void visitOptionalCtType(OptionalCtType optionalCtType, Void aVoid) throw
8585
throw new AptException(
8686
Message.DOMA4301, fieldElement, new Object[] {optionalCtType.getQualifiedName()});
8787
}
88-
return null;
88+
return optionalCtType.getElementCtType().accept(this, aVoid);
8989
}
9090

9191
@Override

doma-processor/src/test/java/org/seasar/doma/internal/apt/AptinaTestCase.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,14 +345,16 @@ private void assertEqualsByLine(
345345
@Override
346346
public void assertMessage(Message message) {
347347
assertCompiled();
348+
var unmatchedMessages = new ArrayList<Message>();
348349
for (Diagnostic<? extends JavaFileObject> diagnostic : getDiagnostics()) {
349350
Message m = extractMessage(diagnostic);
350351
if (m == message) {
351352
// found
352353
return;
353354
}
355+
unmatchedMessages.add(m);
354356
}
355-
fail();
357+
fail("unmatched messages: " + unmatchedMessages);
356358
}
357359

358360
private Message extractMessage(Diagnostic<? extends JavaFileObject> diagnostic) {

doma-processor/src/test/java/org/seasar/doma/internal/apt/processor/embeddable/EmbeddableProcessorTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContex
154154
LombokAllArgsConstructorAccess_none.class,
155155
Message.DOMA4427,
156156
"-Adoma.lombok.AllArgsConstructor=" + AllArgsConstructor.class.getName()),
157-
invocationContext(Outer__illegalName.class, Message.DOMA4417));
157+
invocationContext(Outer__illegalName.class, Message.DOMA4417),
158+
invocationContext(IllegalOptionalProperty.class, Message.DOMA4298));
158159
}
159160

160161
private TestTemplateInvocationContext invocationContext(
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright Doma Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.seasar.doma.internal.apt.processor.embeddable;
17+
18+
import java.net.URL;
19+
import java.util.Optional;
20+
import org.seasar.doma.Embeddable;
21+
22+
@Embeddable
23+
public record IllegalOptionalProperty(Optional<URL> url) {}

0 commit comments

Comments
 (0)